Example #1
0
        /// <summary>
        /// 分页输出
        /// </summary>
        private string CreatePageList(LiveRecommandNode recommand, List <LiveVideoNode> videos, LiveNavFilter filter, VideoPars pars, bool isEx)
        {
            var vkey = new VideoNodeKey(filter.platform, 0, filter.auth);
            var xml  = new XElement("vlist");

            xml.Add(new XElement("nav_id", recommand.ID));
            xml.Add(new XElement("nav_name", recommand.Language[filter.lang].Title));
            xml.Add(new XElement("count", videos.Count));
            xml.Add(new XElement("page_count", PageUtils.PageCount(videos.Count, filter.c)));
            if (filter.c != 0 && filter.s != 0)
            {
                //currentVideos = videos.Skip(filter.c * (filter.s - 1)).Take(filter.c).ToList();
                xml.Add(new XElement("countInPage", filter.c));
                xml.Add(new XElement("page", filter.s));

                var index = (filter.s - 1) * filter.c;
                var max   = index + filter.c;
                if (max > videos.Count)
                {
                    max = videos.Count;
                }
                for (var i = index; i < max; i++)
                {
                    xml.Add(VideoResponseUtils.CustomLiveListRes(videos[i], filter, 0, isEx));
                }
            }
            else
            {
                xml.Add(from v in videos select VideoResponseUtils.CustomLiveListRes(v, filter, 0, isEx));
            }
            return(xml.ToString(SaveOptions.DisableFormatting));
        }
Example #2
0
 /// <summary>
 /// 生成基本导航分类
 /// </summary>
 private XElement CreateNav(LiveRecommandNode recommand, LiveNavFilter filter)
 {
     return(new XElement("nav",
                         new XElement("navid", recommand.ID),
                         new XElement("name", recommand.Language[filter.lang].Title),
                         new XElement("image", recommand.PicLink)
                         ));
 }
Example #3
0
        /// <summary>
        /// 过滤不符合条件的频道
        /// </summary>
        private List <LiveVideoNode> FilterList(LiveRecommandNode recommand, List <Func <VideoBase, ExFilterBase, bool> > filters, LiveNavFilter filter)
        {
            var videos = new List <LiveVideoNode>();

            foreach (var video in recommand.Lists)
            {
                bool result = true;
                foreach (var f in filters)
                {
                    result = result && f(video, filter);
                }
                if (result)
                {
                    videos.Add(video);
                }
            }
            return(videos);
        }
Example #4
0
        /// <summary>
        /// 分页输出
        /// </summary>
        private string CreatePageList(LiveRecommandNode recommand, List<LiveVideoNode> videos, LiveNavFilter filter, VideoPars pars, bool isEx)
        {
            var vkey = new VideoNodeKey(filter.platform, 0, filter.auth);
            var xml = new XElement("vlist");
            xml.Add(new XElement("nav_id", recommand.ID));
            xml.Add(new XElement("nav_name", recommand.Language[filter.lang].Title));
            xml.Add(new XElement("count", videos.Count));
            xml.Add(new XElement("page_count", PageUtils.PageCount(videos.Count, filter.c)));
            if (filter.c != 0 && filter.s != 0)
            {
                //currentVideos = videos.Skip(filter.c * (filter.s - 1)).Take(filter.c).ToList();
                xml.Add(new XElement("countInPage", filter.c));
                xml.Add(new XElement("page", filter.s));

                var index = (filter.s - 1) * filter.c;
                var max = index + filter.c;
                if (max > videos.Count)
                    max = videos.Count;
                for (var i = index; i < max; i++)
                {
                    xml.Add(VideoResponseUtils.CustomLiveListRes(videos[i], filter, 0, isEx));
                }
            }
            else
            {
                xml.Add(from v in videos select VideoResponseUtils.CustomLiveListRes(v, filter, 0, isEx));
            }
            return xml.ToString(SaveOptions.DisableFormatting);
        }
Example #5
0
 /// <summary>
 /// 过滤不符合条件的频道
 /// </summary>
 private List<LiveVideoNode> FilterList(LiveRecommandNode recommand, List<Func<VideoBase, ExFilterBase, bool>> filters, LiveNavFilter filter)
 {
     var videos = new List<LiveVideoNode>();
     foreach (var video in recommand.Lists)
     {
         bool result = true;
         foreach (var f in filters)
             result = result && f(video, filter);
         if (result)
             videos.Add(video);
     }
     return videos;
 }
Example #6
0
 /// <summary>
 /// 生成扩展导航分类
 /// </summary>
 private XElement CreateNavEx(LiveRecommandNode recommand, int count, LiveNavFilter filter)
 {
     return new XElement("nav",
         new XElement("navid", recommand.ID),
         new XElement("name", recommand.Language[filter.lang].Title),
         new XElement("count", count),
         new XElement("image", recommand.PicLink)
         );
 }