Beispiel #1
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);
        }
Beispiel #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);
        }
Beispiel #3
0
        public void ParseHtml(string url, ref ShareThread shareThread)
        {
            string htmlContent = HttpCollects.GetHTMLContent(url);

            if (string.IsNullOrEmpty(htmlContent))
            {
                return;
            }

            shareThread = new ShareThread(url, GetPlayerUrlString(url), MediaType.Video, HttpCollects.GetTitle(htmlContent, true), HttpCollects.GetDescription(htmlContent, true), GetThumbnailUrlString(htmlContent, true), DateTime.Now);
        }
Beispiel #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);
        }
Beispiel #5
0
        public void ParseHtml(string url, ref ShareThread shareThread)
        {
            string ThumbnailUrlString = string.Empty;
            string htmlContent        = HttpCollects.GetHTMLContent(url);

            if (string.IsNullOrEmpty(htmlContent))
            {
                return;
            }


            string PlayerUrl = GetPlayerUrlString(url, htmlContent, out ThumbnailUrlString);//换取url里的参数来设置播放器地址并且从页面里获取播放器地址的参数Sid和缩略图

            //新实例
            shareThread = new ShareThread(url, PlayerUrl, MediaType.Video, HttpCollects.GetTitle(htmlContent, true), HttpCollects.GetDescription(htmlContent, true), ThumbnailUrlString, DateTime.Now);

            return;
        }
Beispiel #6
0
        /// <summary>
        /// 获取分享视频详细内容
        /// </summary>
        /// <param name="aid">分享视频编号</param>
        public ShareThreadDetailsModel GetOneShareThreadContentByID(Guid aid)
        {
            IRepository <ShareThread> rep = Factory.Factory <IRepository <ShareThread> > .GetConcrete <ShareThread>();

            IRepository <BlogComment> commentRep = Factory.Factory <IRepository <BlogComment> > .GetConcrete <BlogComment>();

            ShareThread             sharethread = null;
            ShareThreadDetailsModel target      = null;

            var comments = commentRep.FindAll(new Specification <BlogComment>(c => c.TargetId == aid).OrderBy(c => c.CreationDate).Skip(0).Take(10000));
            IList <CommentDspModel> cmodels = new List <CommentDspModel>();

            foreach (BlogComment c in comments)
            {
                CommentDspModel tmp = new CommentDspModel()
                {
                    AccountID = c.AccountInfo.Id, CommentContent = c.Body, CommentID = c.Id, CreatedOn = c.CreationDate, TargetID = c.TargetId, UserName = c.AccountInfo.UserName
                };
                cmodels.Add(tmp);
            }

            try
            {
                sharethread = rep.GetByKey(aid);

                target = new ShareThreadDetailsModel()
                {
                    RawUrl       = sharethread.RawUrl,
                    Body         = sharethread.Body,
                    PlayUrl      = sharethread.PlayUrl,
                    Subject      = sharethread.Subject,
                    ThumbnailUrl = sharethread.ThumbnailUrl,
                    ShareTime    = sharethread.ShareTime,
                    Comments     = cmodels
                };
            }

            catch (Exception error)
            {
                throw new Exception(error.Message);
            }

            return(target);
        }
Beispiel #7
0
 /// <summary>
 /// 解析url地址获取数据
 /// </summary>
 /// <param name="url">原始Url地址</param>
 /// <param name="shareThread">分享对象</param>
 public static void ParseHtml(string url, ref ShareThread shareThread)
 {
     Instance(url).ParseHtml(url, ref shareThread);
 }