Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string url     = Request.Form["input_box"];
            string comment = Request.Form["subject"];
            string title   = Request.Form["videoname"];

            if (!string.IsNullOrEmpty(url))
            {
                //if (Context.User.Identity.IsAuthenticated && !string.IsNullOrEmpty(Context.User.Identity.Name))
                //{
                //UserInfoService uis = new UserInfoService();
                //UserStateModel umodel = uis.GetUserInfo(new Guid(Context.User.Identity.Name));

                //获取视频信息
                //NewVideoModel model = new NewVideoModel() { RawUrl = url, Sharer = umodel, Comment = comment };
                try
                {
                    NewVideoModel model = new NewVideoModel()
                    {
                        RawUrl = url, Sharer = null, Comment = comment,
                    };
                    ShareThreadService mservice = new ShareThreadService();

                    mservice.CreateShareThread(model, url, "新闻", title);
                    Response.Write("<script type='text/javascript'>self.close()</script>");
                    Response.Write("<script type='text/javascript'>alert('创建视频成功!')</script>");
                }
                catch (Exception error)
                {
                    throw new Exception("视频路径不正确");
                }
                //}
            }
        }
Example #2
0
        public void CreateShareThread(NewVideoModel model, string url, string source, string title)
        {
            ShareThread st = null;

            VideoShareProvider.ParseHtml(model.RawUrl, ref st);
            string subject  = string.Empty;
            string toDelete = " - 视频 - 优酷视频 - 在线观看";

            if (string.IsNullOrEmpty(title))
            {
                if (st.Subject.IndexOf(toDelete) >= 0)
                {
                    subject = st.Subject.Substring(0, st.Subject.IndexOf(toDelete));//并不是每一个网站都使用此过滤标记,暂时使用
                }
                else
                {
                    subject = st.Subject;
                }
            }
            else
            {
                subject = title;
            }
            ShareThreadService  mservice = new ShareThreadService();
            NewShareThreadModel newmodel = new NewShareThreadModel()
            {
                Body = st.Body, PlayUrl = st.PlayUrl, RawUrl = url, ShareTime = DateTime.Now, Subject = subject, ThumbnailUrl = st.ThumbnailUrl, Source = source
            };

            this.CreateShareThread(newmodel);
        }
Example #3
0
        /// <summary>
        /// 分享新视频
        /// </summary>
        /// <param name="model">新视频模型</param>
        public void NewVideo(NewVideoModel model)
        {
            ShareThread st = null;

            VideoShareProvider.ParseHtml(model.RawUrl, ref st);
            string identify = DateTime.Now.Ticks.ToString();

            //如果评论为空则用视频默认标题
            string subject = string.IsNullOrEmpty(model.Comment) ? st.Subject : model.Comment;

            string finalSubject = "<a href='##' onclick=\"playVideo('" + identify + "')\" >" + subject + "</a>";

            //视频内容html
            string content = "<div class='video' id='prev_" + identify + "' style='background-image: url(" + st.ThumbnailUrl + ");'><a onclick=\"playVideo('" + identify + "')\" href='###'>播放</a></div>";

            content += "<div class='blogPicOri' id='disp_" + identify + "' style='visibility: visible; display: none; '><p><cite><a onclick=\"stopVideo('" + identify + "')\" title='收起' href='###'>收起</a></cite><cite class='MIB_line_l'>|</cite><cite class='MIB_line_l'>|</cite></p>";

            //播放器脚本
            content += "<embed id='JSONP_167HAG6ED_9' height='356' allowscriptaccess='always' style='visibility: visible;' pluginspage='http://get.adobe.com/cn/flashplayer/' flashvars='playMovie=true&amp;auto=1&amp;adss=0' width='380' allowfullscreen='true' quality='hight' src='" + st.PlayUrl + "' type='application/x-shockwave-flash' wmode='transparent'></div>";

            NewFeedModel fmodel = new NewFeedModel()
            {
                Sharer = model.Sharer, Type = FeedType.NewVideo, Subject = finalSubject, Content = content
            };
            BlogService         bservice     = new BlogService();
            ShareThreadService  shareservice = new ShareThreadService();
            NewShareThreadModel sharemodel   = new NewShareThreadModel()
            {
                Body = st.Body, PlayUrl = st.PlayUrl, RawUrl = model.RawUrl, ShareTime = DateTime.Now, Source = "博客", Subject = st.Subject, ThumbnailUrl = st.ThumbnailUrl
            };

            shareservice.CreateShareThread(sharemodel);
            bservice.CreateFeed(fmodel);
        }
Example #4
0
        public void CreateShareThread(NewVideoModel model, string url, string source)
        {
            ShareThread st = null;

            VideoShareProvider.ParseHtml(model.RawUrl, ref st);
            ShareThreadService  mservice = new ShareThreadService();
            NewShareThreadModel newmodel = new NewShareThreadModel()
            {
                Body = st.Body, PlayUrl = st.PlayUrl, RawUrl = url, ShareTime = DateTime.Now, Subject = st.Subject, ThumbnailUrl = st.ThumbnailUrl, Source = source
            };

            this.CreateShareThread(newmodel);
        }
Example #5
0
        public GenericIdModel Register(string token, [FromBody] NewVideoModel video)
        {
            GenericIdModel gsm = new GenericIdModel();

            gsm.Result           = 0;
            gsm.ResultComplement = "";
            gsm.Id = "";

            int    lang = LibVisLib.Verify.ValidLanguage(video.Lang);
            RacMsg msgs = RacMsg.cache.GetMessage((RacMsg.Language)lang);

            // Verifica o token de autenticação

            string machine = HttpContext.Features.Get <IHttpConnectionFeature>()?.RemoteIpAddress.ToString();

            string userId = SessionCode.ValidateSessionCode(token, machine);

            if (userId == null)
            {
                gsm.Result           = (int)RacMsg.Id.InvalidToken;
                gsm.ResultComplement = msgs.Get(RacMsg.Id.InvalidToken);
            }

            LibVisLib.Profile prf = LibVisLib.Profile.LoadProfile(userId);
            if (prf == null)
            {
                gsm.Result           = (int)RacMsg.Id.UserNotFound;
                gsm.ResultComplement = msgs.Get(RacMsg.Id.UserNotFound);
            }

            if (gsm.Result == 0)
            {
                if (prf.user.profile < BaseUser.InternalSystemProfile.InternalStaff)
                {
                    gsm.Result           = (int)RacMsg.Id.UserHasNoRightToThisItem;
                    gsm.ResultComplement = msgs.Get(RacMsg.Id.UserHasNoRightToThisItem);
                }

                try
                {
                    if (!LibVisLib.Verify.AcceptInteger(video.Categ))
                    {
                        gsm.Result            = (int)RacLib.RacMsg.Id.Error;
                        gsm.ResultComplement += msgs.Get(RacMsg.Id.InvalidCharsInCategories) + "; ";
                        RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errCateg: Invalid chars");
                    }

                    string r0 = "";
                    if (!LibVisLib.Verify.AcceptFreeText(video.Title, ref r0))
                    {
                        gsm.Result            = (int)RacLib.RacMsg.Id.Error;
                        gsm.ResultComplement += msgs.Get(RacMsg.Id.InvalidCharactersInTitle) + " (" + r0 + "); ";
                        RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errTitle: Invalid chars");
                    }

                    string r1 = "";
                    if (!LibVisLib.Verify.AcceptMultilineFreeText(video.Description, ref r1))
                    {
                        gsm.Result            = (int)RacLib.RacMsg.Id.Error;
                        gsm.ResultComplement += msgs.Get(RacMsg.Id.InvalidCharactersInText) + " (" + r1 + "); ";
                        RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errDescription: Invalid chars  (" + r1 + "); ");
                    }

                    string r2 = "";
                    if (!LibVisLib.Verify.AcceptFreeText(video.Tags, ref r2))
                    {
                        gsm.Result            = (int)RacLib.RacMsg.Id.Error;
                        gsm.ResultComplement += msgs.Get(RacMsg.Id.InvalidCharactersInTags) + " (" + r2 + "); ";
                        RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errTags: Invalid chars");
                    }

                    r1 = "";
                    if (!LibVisLib.Verify.AcceptFreeText(video.Image, ref r1))
                    {
                        gsm.Result            = (int)RacLib.RacMsg.Id.Error;
                        gsm.ResultComplement += msgs.Get(RacMsg.Id.InvalidCharactersInImageData) + " (" + r1 + "); ";
                        RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errImage: Invalid chars (imagem base64) (" + r1 + "); ");
                    }

                    if (!LibVisLib.Verify.AcceptUrl(video.YoutubeLink))
                    {
                        gsm.Result            = (int)RacLib.RacMsg.Id.Error;
                        gsm.ResultComplement += msgs.Get(RacMsg.Id.InvalidCharactersInYoutubeUrl) + "; ";
                        RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errYoutubeLink: Invalid chars");
                    }

                    if (!LibVisLib.Verify.AcceptUrl(video.BitchuteLink))
                    {
                        gsm.Result            = (int)RacLib.RacMsg.Id.Error;
                        gsm.ResultComplement += msgs.Get(RacMsg.Id.InvalidCharactersInBitchuteUrl) + "; ";
                        RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errBitchuteLink: Invalid chars");
                    }

                    r1 = "";
                    if (!LibVisLib.Verify.AcceptMultilineFreeText(video.Script, ref r1))
                    {
                        gsm.Result            = (int)RacLib.RacMsg.Id.Error;
                        gsm.ResultComplement += msgs.Get(RacMsg.Id.InvalidCharactersInTheVideoScript) + "; ";
                        RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errDescription: Invalid chars  (" + r1 + "); ");
                    }

                    string imagem = video.Image;

                    string[] imagempart = imagem.Split(',');

                    if (imagempart.Length > 0)
                    {
                        imagem = imagempart[imagempart.Length - 1];
                    }

                    string title        = LibVisLib.Verify.VerifyFreeText(video.Title);
                    string description  = LibVisLib.Verify.VerifyMultilineFreeText(video.Description);
                    string tags         = LibVisLib.Verify.VerifyFreeText(video.Tags);
                    string categ        = LibVisLib.Verify.VerifyInteger(video.Categ);
                    string youtubelink  = LibVisLib.Verify.VerifyUrl(video.YoutubeLink);
                    string bitchutelink = LibVisLib.Verify.VerifyUrl(video.BitchuteLink);
                    string script       = LibVisLib.Verify.VerifyMultilineFreeText(video.Script);

                    if (title.Length < 10)
                    {
                        gsm.Result            = (int)RacLib.RacMsg.Id.Error;
                        gsm.ResultComplement += msgs.Get(RacMsg.Id.TitleTooShort) + "; ";
                        RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errTitle: required at least 10 chars");
                    }

                    if (title.Length > 150)
                    {
                        gsm.Result            = (int)RacLib.RacMsg.Id.Error;
                        gsm.ResultComplement += msgs.Get(RacMsg.Id.TitleTooLong) + "; ";
                        RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errTitle: Content too big");
                    }

                    if (description.Length < 10)
                    {
                        gsm.Result            = (int)RacLib.RacMsg.Id.Error;
                        gsm.ResultComplement += msgs.Get(RacMsg.Id.TextTooShort) + "; ";
                        RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errTexto: required at least 10 chars");
                    }

                    if (description.Length > 5000)
                    {
                        gsm.Result            = (int)RacLib.RacMsg.Id.Error;
                        gsm.ResultComplement += msgs.Get(RacMsg.Id.TextTooLong) + "; ";
                        RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errDescription: Content too big");
                    }

                    if (script.Length > 100000)
                    {
                        gsm.Result            = (int)RacLib.RacMsg.Id.Error;
                        gsm.ResultComplement += msgs.Get(RacMsg.Id.ScriptTooLong) + "; ";
                        RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errScript: Content too big");
                    }

                    if (imagem.Length > 5000000)
                    {
                        gsm.Result            = (int)RacLib.RacMsg.Id.Error;
                        gsm.ResultComplement += msgs.Get(RacMsg.Id.ImageTooLarge) + "; ";
                        RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errImage: Content too big");
                    }

                    if (gsm.Result == 0)
                    {
                        LibVisLib.Video vid = new Video();

                        vid.title        = title;
                        vid.description  = description;
                        vid.released     = DateTime.Now;
                        vid.script       = script;
                        vid.linkBitchute = bitchutelink;
                        vid.linkYoutube  = youtubelink;
                        vid.tags         = tags;
                        vid.language     = (RacMsg.Language)lang;

                        vid.categories = new List <string>();

                        int ic = 0;
                        for (int i = 0; i < LibVisLib.Category.categories.Count; i++)
                        {
                            if (!LibVisLib.Category.categories[i].main)
                            {
                                if (ic < categ.Length && categ[ic++] == '1')
                                {
                                    vid.categories.Add(Category.categories[i].label);
                                }
                            }
                        }

                        vid.NormalizeMain();
                        vid.Save();


                        byte[] str = Convert.FromBase64String(imagem);

                        MemoryStream ms = new MemoryStream(str, 0, str.Length);
                        ms.Write(str, 0, str.Length);
                        System.Drawing.Image img = System.Drawing.Image.FromStream(ms, true);

                        string path = Base.conf.tempImageFilePath + "\\v-" + vid.id + ".jpg";

                        img.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg);


                        VideoAction act = new VideoAction(vid);

                        act.date        = vid.released;
                        act.type        = VideoAction.ActionType.Created;
                        act.userId      = userId;
                        act.show        = true;
                        act.observation = "";

                        act.Save();

                        //prf.RegisterAction(Profile.ProfileAction.Reg);

                        gsm.Id = vid.id;
                    }
                }
                catch (Exception ex)
                {
                    if (!ex.Message.StartsWith("Thread was being aborted"))
                    {
                        gsm.Result            = (int)RacLib.RacMsg.Id.InternalError;
                        gsm.ResultComplement += ex.Message;
                        RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.InternalError, "Exception in form");
                        RacLib.BaseLog.log.Log(ex);
                    }
                }
            }

            return(gsm);
        }