Beispiel #1
0
        public async Task <ActionResult> getinfo()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var data = JsonConvert.DeserializeObject <ForumEntity>(json);

            var _posts = await ForumBLLC.LoadItems(_context, data);

            if (_posts.Count > 0)
            {
                // array of associate category list
                _posts[0].category_list = await CategoryContentsBLL.FetchContentCategoryList(_context, data.id, (byte)CategoryContentsBLL.Types.Forums);

                return(Ok(new { status = "success", post = _posts[0] }));
            }
            else
            {
                return(Ok(new { status = "error", message = SiteConfig.generalLocalizer["_no_records"].Value }));
            }
        }
Beispiel #2
0
        public async Task <ActionResult> getinfo()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var data = JsonConvert.DeserializeObject <BlogEntity>(json);

            data.nofilter = true;
            var _posts = await BlogsBLL.LoadItems(_context, data);

            if (_posts.Count > 0)
            {
                if (_posts[0].picture_url != "")
                {
                    var _pics = _posts[0].picture_url.Split(char.Parse(","));
                    _posts[0].files = new List <FileEntity>();
                    foreach (var pic in _pics)
                    {
                        _posts[0].files.Add(new FileEntity()
                        {
                            filename = pic,
                            img_url  = pic
                        });
                    }
                }

                Setup_Item(_posts[0]);

                _posts[0].author.img_url = UserUrlConfig.ProfilePhoto(_posts[0].author.Id, _posts[0].author.picturename, 0);
                // array of associate category list
                _posts[0].category_list = await CategoryContentsBLL.FetchContentCategoryList(_context, data.id, (byte)CategoryContentsBLL.Types.Blogs);

                return(Ok(new { status = "success", post = _posts[0] }));
            }
            else
            {
                return(Ok(new { status = "error", message = SiteConfig.generalLocalizer["_no_records"].Value }));
            }
        }
Beispiel #3
0
        // GET: media
        public async Task <IActionResult> Index(long?pid)
        {
            if (pid == null)
            {
                return(Redirect(Config.GetUrl("videos")));
            }

            var model = new VideoViewModel();

            model.isAllowed = true;

            /*if (HttpContext.Request.Query["status"].Count > 0)
             * {
             *  if (HttpContext.Request.Query["status"] == "pending")
             *      model.Message = SiteConfig.sharedLocalizer["video_message_02"]; // Video has been posted and will be appear shortly.
             * }*/

            var _list = await VideoBLL.LoadItems(_context, new VideoEntity()
            {
                id         = (long)pid,
                ispublic   = false,
                issummary  = false,
                isdropdown = false,
                nofilter   = true
            });

            if (_list.Count == 0)
            {
                model.isAllowed     = false;
                model.DetailMessage = SiteConfig.generalLocalizer["_no_records"].Value;
                return(View(model));
            }

            model.Data = _list[0];

            // fetch associated categories
            model.Data.category_list = await CategoryContentsBLL.FetchContentCategoryList(_context, _list[0].id, (byte)CategoryContentsBLL.Types.Videos);

            model.PreviewUrl = VideoUrlConfig.PrepareUrl(model.Data);

            if (model.Data.isadult == (byte)AdultTypes.Adult)
            {
                // 1:-> adult content, 0:-> non adult content
                var getValue = HttpContext.Session.GetString("adultmember");
                if (getValue == null)
                {
                    return(Redirect(Config.GetUrl("home/validateadult?surl=" + WebUtility.UrlEncode(model.PreviewUrl) + "")));
                }
            }

            // premium check
            if (_list[0].isfeatured == (byte)FeaturedTypes.Premium)
            {
                // content is marked as premium
                if (!User.Identity.IsAuthenticated)
                {
                    Response.Redirect(Config.GetUrl("login?ReturnUrl=" + WebUtility.UrlEncode(model.PreviewUrl) + ""), true);
                    return(View(model));
                }
                if (Jugnoon.Settings.Configs.PremiumSettings.premium_option == 1)
                {
                    // check for subscription
                    if (!UserPackagesBLL.Check_membership(_context, SiteConfig.userManager.GetUserName(User)))
                    {
                        // redirect to purchase page
                        Response.Redirect(Config.GetUrl("account/payment/packages?status=noaccess&surl=" + WebUtility.UrlEncode(model.PreviewUrl) + ""));
                        return(View(model));
                    }
                }
                else
                {
                    // credit base purchase view implementation logic required here.
                }
            }

            if (_list[0].isapproved == 0)
            {
                model.Message = SiteConfig.videoLocalizer["_video_pending_status"]; // Video is pending for moderator approval
            }
            if (_list[0].isenabled == (byte)EnabledTypes.Disabled)
            {
                model.isAllowed     = false;
                model.DetailMessage = SiteConfig.videoLocalizer["_video_blocked_status"]; // Video has been blocked. contact site administrator for more detail
                return(View(model));
            }

            var _Path = "videos/";

            if (_list[0].type == 1)
            {
                _Path = "audio/";
            }

            model.Info = new InfoViewModel()
            {
                ContentID      = model.Data.id,
                Description    = model.Data.description,
                Created_at     = model.Data.created_at,
                Author         = model.Data.author,
                Category       = model.Data.category_list,
                Tags           = model.Data.tags,
                Liked          = model.Data.liked,
                Disliked       = model.Data.disliked,
                Total_Ratings  = model.Data.total_rating,
                Average_Rating = model.Data.avg_rating,
                MediaType      = model.Data.type,
                Path           = _Path
            };

            // simple view statistics
            _list[0].views = _list[0].views + 1;
            VideoBLL.Update_Field_V3(_context, (long)pid, model.Data.views, "views");

            model.Data.views++;

            // Video Path settings
            string VideoPath   = "";
            string PictureName = "";

            if (model.Data.type == 0)
            {
                // video settings
                // if streamoutputs exist, video transcoded via Elastic Trancoder. It have own setup below.
                if (_list[0].streamoutputs == null || _list[0].streamoutputs == "")
                {
                    VideoPath = VideoUrlConfig.Return_FLV_Video_Url(model.Data.pub_url, model.Data.userid) + "/" + model.Data.videofilename;

                    /*string MP4Path = "";
                     * if (VideoPath.EndsWith(".webm"))
                     *  MP4Path = VideoPath.Replace(".webm", ".mp4");*/
                }

                if (model.Data.thumb_url != "none")
                {
                    PictureName = model.Data.thumb_url;
                }
                else
                {
                    PictureName = VideoUrlConfig.Return_Video_Thumb_Url(model.Data.thumb_url, model.Data.userid) + "/" + model.Data.thumbfilename;
                }
            }
            else
            {
                // audio settings
                VideoPath = VideoUrlConfig.Return_MP3_Audio_Url(model.Data.pub_url, model.Data.userid) + "/" + model.Data.videofilename;
                if (model.Data.thumb_url != "none")
                {
                    PictureName = model.Data.thumb_url;
                }
                else if (_list[0].coverurl.StartsWith("http"))
                {
                    PictureName = _list[0].coverurl;
                }
                else
                {
                    PictureName = VideoUrlConfig.Return_Video_Thumb_Url(model.Data.thumb_url, model.Data.userid) + "/" + model.Data.thumbfilename;
                }
            }


            string _script   = _list[0].embed_script;
            string _videoUrl = "";

            if (_list[0].preview_url != null && _list[0].preview_url != "")
            {
                _videoUrl = _list[0].preview_url;
            }
            else
            {
                _videoUrl = _list[0].pub_url;
            }

            model.Player = new VideoJsModelView()
            {
                EmbedScript = "",
                Type        = model.Data.type
            };

            if (_list[0].coverurl != null && _list[0].coverurl != "")
            {
                model.Player.PictureUrl = _list[0].coverurl;
            }
            else
            {
                model.Player.PictureUrl = PictureName;
            }

            // attach video data with player model
            // useful when you bind some video data within player
            model.Player.Data = _list[0];

            if (model.Data.type == 0)
            {
                // video player settings
                // if AWS Uploader Enabled
                if (_list[0].streamoutputs != null && _list[0].streamoutputs != "")
                {
                    // enabled advance adaptive streaming / mpeg-dash / hls
                    model.Player.enabledAWS = true;
                    model.Player.VideoFeed  = new List <SupportedVideos>();
                    var supportedStreamOptions = _list[0].streamoutputs.Split(char.Parse(","));
                    foreach (var option in supportedStreamOptions)
                    {
                        /*if (option == "mpegdash")
                         * {
                         *  //CloudFront.CreateCannedPrivateURL(_list[0].pub_url + "mpegdash.mpd", 3000),
                         *  model.Player.VideoFeed.Add(new SupportedVideos()
                         *  {
                         *      src = CloudFront.CreateCannedPrivateURL(_list[0].pub_url + "mpegdash.mpd", 900),
                         *      type = "application/dash+xml"
                         *  });
                         * }
                         *
                         * if (option == "hls")
                         * {
                         *  // CloudFront.CreateCannedPrivateURL(_list[0].pub_url + "hls.m3u8", 3000),
                         *  model.Player.VideoFeed.Add(new SupportedVideos()
                         *  {
                         *      src = CloudFront.CreateCannedPrivateURL(_list[0].pub_url + "hls.m3u8", 900),
                         *      type = "application/x-mpegURL"
                         *  });
                         * }*/
                        // temporary replace private url with public url
                        var url = _list[0].pub_url.Replace(Jugnoon.Videos.Configs.AwsSettings.private_url, Jugnoon.Videos.Configs.AwsSettings.public_url);
                        if (option == "mp4_480")
                        {
                            model.Player.VideoFeed.Add(new SupportedVideos()
                            {
                                //src = CloudFront.CreateCannedPrivateURL(_list[0].pub_url.Replace("d1fpw0dove1bub.cloudfront.net", "d16gr1zx2upz2x.cloudfront.net") + "menifest_480.mp4",900),
                                src  = url + "menifest_480.mp4",
                                type = "video/mp4"
                            });
                        }
                        // enable hd streaming (make sure it is enabled in AWS Lambda to publish

                        /*if (option == "mp4_720")
                         * {
                         *  model.Player.VideoFeed.Add(new SupportedVideos()
                         *  {
                         *      src = CloudFront.CreateCannedPrivateURL(_list[0].pub_url + "menifest_720.mp4", 3000),
                         *      type = "video/mp4"
                         *  });
                         * }*/
                    }
                }
                // If cloud enabled
                else if (_script != "" || _list[0].youtubeid != "")
                {
                    // third party embed video script enabled
                    if (_script == "")
                    {
                        model.Player.EmbedScript = _list[0].youtubeid;
                    }
                    else
                    {
                        model.Player.EmbedScript = _script;
                    }
                }
                else if (_videoUrl.StartsWith("http"))
                {
                    // cloud front streaming
                    model.Player.VideoUrl = CloudFront.CreateCannedPrivateURL(_videoUrl, 60);
                }
                else if (_list[0].videofilename.EndsWith("mp4"))
                {
                    if (TokenBLL.isTokenEnabled)
                    {
                        // Token Based Stream Authentication Enabled
                        // Recommended to stream on HTML5 Players
                        string maxParam = VideoBLL.GenerateBandwidthParam();
                        string Token    = TokenBLL.Add(_context);
                        model.Player.VideoUrl = "/stream/token.ashx?f=" + _list[0].videofilename + "&u=" + _list[0].userid + "&tk=" + Token + "" + maxParam;
                        if (_list[0].originalvideofilename.EndsWith(".png"))
                        {
                            model.Player.PictureUrl = "/contents/member/" + _list[0].userid + "/thumbs/" + _list[0].originalvideofilename;
                        }
                    }
                    else if (VideoBLL.EnableHttpStreaming)
                    {
                        // Http Streaming Enabled
                        // Recommended to stream on HTML5 Players
                        string maxParam = VideoBLL.GenerateBandwidthParam();
                        model.Player.VideoUrl = "/stream/stream.ashx?f=" + _list[0].videofilename + "&u=" + _list[0].userid + "" + maxParam;
                    }
                    else
                    {
                        // Direct Play
                        model.Player.VideoUrl = VideoPath;
                    }
                }
                else
                {
                    // load and play videos normally
                    model.Player.VideoUrl = VideoPath;
                }
            }
            else
            {
                // audio player settings
                model.Player.VideoUrl   = VideoPath;
                model.Player.PictureUrl = PictureName;
            }

            model.Action = new ActionViewModel()
            {
                ContentID    = (long)pid,
                Liked        = _list[0].liked,
                Disliked     = _list[0].disliked,
                UserName     = _list[0].userid,
                Favorites    = _list[0].favorites,
                FileName     = model.Data.videofilename,
                VideoPath    = VideoPath,
                isRating     = _list[0].isratings,
                Views        = _list[0].views,
                Comments     = _list[0].comments,
                Content_Type = "video",
                isEmbed      = true,
                MediaType    = model.Data.type,
                Ratingtype   = 1, // 0: like / dislike, 1: rating
                Avg_Ratings  = _list[0].avg_rating,
                Ratings      = _list[0].ratings,
                TotalRatings = _list[0].total_rating,
                isDownload   = false
            };


            model.Comments = new CommentViewModel()
            {
                isComment = _list[0].iscomments
            };

            string meta_title = _list[0].title;

            if (meta_title == "")
            {
                meta_title = "Media No " + _list[0].id;
            }

            string _desc = UtilityBLL.StripHTML(_list[0].description);

            if (_desc == "")
            {
                _desc = _list[0].title;
            }
            else if (_desc.Length > 160)
            {
                _desc = _desc.Substring(0, 160);
            }

            ViewBag.title       = meta_title;
            ViewBag.description = _desc + ", date uploaded: " + _list[0].created_at + ", VID: " + _list[0].id;

            return(View(model));
        }
Beispiel #4
0
        // GET: post
        public async Task <IActionResult> Index(long?id, string title)
        {
            if (id == null)
            {
                return(Redirect(Config.GetUrl("blogs")));
            }

            var model = new PostViewModel();

            model.isExist = true;

            var _lst = await BlogsBLL.LoadItems(_context, new BlogEntity()
            {
                id         = (long)id,
                isapproved = ApprovedTypes.All,
                ispublic   = false,
                isenabled  = EnabledTypes.Enabled
            });

            if (_lst.Count == 0)
            {
                model.isExist = false;
                return(View(model));
            }

            model.Post = _lst[0];
            // fetch associated categories
            model.Post.category_list = await CategoryContentsBLL.FetchContentCategoryList(_context, model.Post.id, (byte)CategoryContentsBLL.Types.Blogs);

            model.PermaUrl = BlogUrlConfig.Generate_Post_Url(new JGN_Blogs()
            {
                id    = (long)id,
                title = model.Post.title
            });

            if (model.Post.isadult == 1)
            {
                // 1:-> adult content, 0:-> non adult content
                var getValue = HttpContext.Session.GetString("adultmember");
                if (getValue == null)
                {
                    return(Redirect(Config.GetUrl("default/validateadult?surl=" + WebUtility.UrlEncode(model.PermaUrl) + "")));;
                }
            }

            // increment views
            model.Post.views++;
            BlogsBLL.Update_Field_V3(_context, (long)id, _lst[0].views, "views");

            string meta_title = _lst[0].title;

            if (meta_title == "")
            {
                meta_title = "Post ID: " + _lst[0].id;
            }

            ViewBag.title = meta_title;

            string _desc = UtilityBLL.StripHTML(_lst[0].description);

            if (_desc == "")
            {
                _desc = _lst[0].title;
            }
            else if (_desc.Length > 160)
            {
                _desc = _desc.Substring(0, 160);
            }

            ViewBag.description = _desc + ", posted date: " + _lst[0].created_at + ", PostID: " + _lst[0].id;

            ViewBag.RSS = Config.GetUrl("agency/rss");

            ViewBag.ATOM = Config.GetUrl("agency/atom");

            return(View(model));
        }