示例#1
0
 public string LiveRecommandList(LiveNavFilter filter)
 {
     try
     {
         var recommands = LiveRecommandCache.Instance.Items[new RecommandKey(filter.platform, filter.auth, filter.navid)];
         if (recommands.Count <= 0)
         {
             return(NoModeNav());
         }
         var pars    = VideoParsUtils.FormateSearchVideoPars(filter);
         var filters = VideoNodesUtil.CommonCustomFilter(filter);
         if (filters.Count <= 0)
         {
             return(CreatePageList(recommands[0], recommands[0].Lists, filter, pars, false));
         }
         else
         {
             var videos = FilterList(recommands[0], filters, filter);
             return(CreatePageList(recommands[0], videos, filter, pars, false));
         }
     }
     catch (KeyNotFoundException)
     {
         return(NoPlatformNav());
     }
     catch (Exception ex)
     {
         return(BoxUtils.FormatErrorMsg(ex));
     }
 }
示例#2
0
        /// <summary>
        /// XML输出
        /// </summary>
        private void ResponseXml(TreeNode node, XElement xml, TreeleftFilter filter, VideoNodeKey key, bool isEx)
        {
            int count, allcount;

            if (!isEx)
            {
                var filters = VideoNodesUtil.CommonCustomFilter(filter);
                if (filters.Count <= 0)
                {
                    count    = GetChannelCount(node, key);
                    allcount = GetAllChannelCount(node, key) + count;
                }
                else
                {
                    count    = GetChannelExCount(node, key, filters, filter);
                    allcount = GetAllChannelExCount(node, key, filters, filter) + count;
                }
            }
            else
            {
                var filters = VideoNodesUtil.FormateTagFilter(filter);
                count    = GetChannelExCount(node, key, filters, filter);
                allcount = GetAllChannelExCount(node, key, filters, filter) + count;
            }
            xml.Add(new XElement("treeleft",
                                 new XElement("tlid", node.Node.NodeID),
                                 new XElement("father_tlid", node.Node.ParentNodeID),
                                 new XElement("name", node.Language[filter.lang].Title),
                                 new XElement("remark", node.Language[filter.lang].SubTitle),
                                 new XElement("subtreeleft_count", node.Childrens.Count),
                                 new XElement("subtreeleft_totalcount", node.ALLChildrens),
                                 new XElement("subv_count", count),
                                 new XElement("subv_totalcount", allcount)
                                 ));
        }
示例#3
0
 public string LiveRecommandNav(LiveNavFilter filter)
 {
     try
     {
         var recommands = LiveRecommandCache.Instance.Items[new RecommandKey(filter.mode, filter.platform, filter.auth)];
         var root       = new XElement("navs");
         var filters    = VideoNodesUtil.CommonCustomFilter(filter);
         if (filters.Count <= 0)
         {
             root.Add(from recommand in recommands select CreateNav(recommand, filter));
         }
         else
         {
             root.Add(from recommand in recommands let vs = FilterList(recommand, filters, filter) where vs.Count > 0 select CreateNav(recommand, filter));
         }
         return(root.ToString(SaveOptions.DisableFormatting));
     }
     catch (KeyNotFoundException)
     {
         return(NoModeNav());
     }
     catch (Exception ex)
     {
         return(BoxUtils.FormatErrorMsg(ex));
     }
 }
示例#4
0
 public string ImageRecommand(CoverFilter filter)
 {
     try
     {
         var pars    = VideoParsUtils.FormateSearchVideoPars(filter);
         var filters = VideoNodesUtil.CommonCustomFilter(filter);
         var rel     = CoverNavCache.Instance.Dictionary[filter.navid];
         return(CreatePageList(rel, filter, pars, filters, false));
     }
     catch (KeyNotFoundException)
     {
         return(NoPlatformNav());
     }
     catch (Exception ex)
     {
         return(BoxUtils.FormatErrorMsg(ex));
     }
 }
示例#5
0
 /// <summary>
 /// 多维度基本接口
 /// </summary>
 public string MultiTags(TagsFilter filter)
 {
     try
     {
         var dimensions = filter.dimension.Split(SplitArray.LineArray, StringSplitOptions.RemoveEmptyEntries).Distinct();
         var filters    = VideoNodesUtil.CommonCustomFilter(filter);
         var xml        = new XElement("tags");
         foreach (var dimension in dimensions)
         {
             var tags = TagCache.Instance.Items[new TagNodeKey()
                                                {
                                                    Dimension = dimension, Type = filter.type
                                                }];
             var key  = new VideoNodeKey(filter.platform, filter.type, filter.auth);
             IEnumerable <string> query = null;
             if (filters.Count <= 0)
             {
                 query = from tag in tags where tag.Channels.ContainsKey(key) select tag.Language[filter.lang].Title;
             }
             else
             {
                 query = from tag in tags
                         where tag.Channels.ContainsKey(key)
                         let count = GetChannelCount(tag, key, filter, filters)
                                     where count > 0
                                     select tag.Language[filter.lang].Title;
             }
             xml.Add(new XElement("info",
                                  new XAttribute("dimension", dimension),
                                  BoxUtils.GetXmlCData(query.FormatListToStr(SplitArray.Line, 100))
                                  ));
         }
         return(xml.ToString(SaveOptions.DisableFormatting));
     }
     catch (KeyNotFoundException)
     {
         return(NoPlatForm());
     }
     catch (Exception ex)
     {
         return(BoxUtils.FormatErrorMsg(ex));
     }
 }
示例#6
0
 /// <summary>
 /// 直播分类信息基本接口
 /// </summary>
 public string LiveTypes(LiveFilter filter)
 {
     try
     {
         var key     = new VideoNodeKey(filter.platform, filter.type, filter.auth);
         var filters = VideoNodesUtil.CommonCustomFilter(filter);
         var root    = new XElement("types");
         if (filters.Count <= 0)
         {
             root.Add(
                 from livetype in LiveTypeDicCache.Instance.Items
                 where livetype.Channels.ContainsKey(key)
                 select new XElement("type",
                                     new XElement("tid", livetype.ID),
                                     new XElement("name", livetype.Language[filter.lang].Title),
                                     new XElement("image", livetype.PicLink)
                                     ));
         }
         else
         {
             root.Add(from livetype in LiveTypeDicCache.Instance.Items
                      where livetype.Channels.ContainsKey(key)
                      let count = GetChannelCount(livetype, key, filter, filters)
                                  where count > 0
                                  select new XElement("type",
                                                      new XElement("tid", livetype.ID),
                                                      new XElement("name", livetype.Language[filter.lang].Title),
                                                      new XElement("image", livetype.PicLink)
                                                      ));
         }
         return(root.ToString(SaveOptions.DisableFormatting));
     }
     catch (KeyNotFoundException)
     {
         return(NoPlatLive());
     }
     catch (Exception ex)
     {
         return(BoxUtils.FormatErrorMsg(ex));
     }
 }
示例#7
0
 public string Nav(NavFilter filter)
 {
     try
     {
         var res     = RecommandCache.Instance.Items[filter.mode];
         var key     = new VideoNodeKey(filter.platform, 0, filter.auth);
         var filters = VideoNodesUtil.CommonCustomFilter(filter);
         var xml     = new XElement("navs");
         if (filters.Count <= 0)
         {
             xml.Add(from re in res
                     select new XElement("nav",
                                         new XElement("navid", re.Id),
                                         new XElement("name", re.Language[filter.lang].Title),
                                         new XElement("image", re.PicLink)
                                         ));
         }
         else
         {
             xml.Add(from re in res
                     let count = GetChannelCount(re, key, filter, filters)
                                 where count > 0
                                 select new XElement("nav",
                                                     new XElement("navid", re.Id),
                                                     new XElement("name", re.Language[filter.lang].Title),
                                                     new XElement("image", re.PicLink)
                                                     ));
         }
         return(xml.ToString(SaveOptions.DisableFormatting));
     }
     catch (KeyNotFoundException)
     {
         return(NoModeNav());
     }
     catch (Exception ex)
     {
         return(BoxUtils.FormatErrorMsg(ex));
     }
 }