Ejemplo n.º 1
0
 public string ListByTags(ListFilter filter)
 {
     try
     {
         var pindex    = VideoNodeKeyArray.Instance.Items[new VideoNodeKey(filter.platform, 0, filter.auth)];
         var pars      = VideoParsUtils.FormatListByTags(filter);
         var filters   = VideoNodesUtil.FormateVideoFilter(filter, pars);
         var tag       = pars.SortTag.Substring(0, pars.SortTag.LastIndexOf(":"));
         var dimension = pars.SortTag.Substring(pars.SortTag.LastIndexOf(":") + 1);
         IEnumerable <int> channels = new List <int>();
         foreach (var type in BoxTypeCache.Instance.Items.Values)
         {
             var key = new TagNodeKey()
             {
                 Dimension = dimension, Type = type.TypeID
             };
             if (TagCache.Instance.Items.ContainsKey(key))
             {
                 var vkey = new VideoNodeKey(filter.platform, type.TypeID, filter.auth);
                 var node = TagCache.Instance.Items[key].FirstOrDefault(v => v.Language[CustomArray.LanguageArray[0]].Title == tag);
                 if (node != null && node.Channels.ContainsKey(vkey))
                 {
                     channels = channels.Union(node.Channels[vkey]);
                 }
             }
         }
         var query = channels.Where(v =>
         {
             bool result = true;
             var video   = ListCache.Instance.Dictionary[v];
             foreach (var f in filters)
             {
                 result = result && f(video, pars, filter);
             }
             return(result);
         }
                                    );
         return(CreatePageList(query, filter, pars, false));
     }
     catch (KeyNotFoundException)
     {
         return(NoPlatForm());
     }
     catch (Exception ex)
     {
         return(BoxUtils.FormatErrorMsg(ex));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取视频数据基本接口
 /// </summary>
 public string VideoList(ListFilter filter)
 {
     try
     {
         var pars    = VideoParsUtils.FormatVideoPars(filter);
         var vkey    = new VideoNodeKey(filter.platform, filter.type, filter.auth);
         var filters = VideoNodesUtil.FormateVideoFilter(filter, pars);
         IEnumerable <int> channels;
         if (filter.treeleftid != 0)
         {
             var node = TreeNodeCache.Instance.Items[filter.treeleftid];
             if (node.Channels.ContainsKey(vkey))
             {
                 channels = VideoSortUtils <VideoNode> .Sort(node.Channels[vkey], filter);
             }
             else
             {
                 channels = new List <int>();
             }
         }
         else if (!string.IsNullOrEmpty(pars.SortTag))
         {
             try
             {
                 var tag       = pars.SortTag.Substring(0, pars.SortTag.LastIndexOf(":"));
                 var dimension = pars.SortTag.Substring(pars.SortTag.LastIndexOf(":") + 1);
                 var key       = new TagNodeKey()
                 {
                     Dimension = dimension, Type = filter.type
                 };
                 if (TagCache.Instance.Items.ContainsKey(key))
                 {
                     var node = TagCache.Instance.Items[key].FirstOrDefault(v => v.Language[CustomArray.LanguageArray[0]].Title == tag);
                     if (node != null && node.Channels.ContainsKey(vkey))
                     {
                         channels = node.Channels[vkey];
                     }
                     else
                     {
                         channels = new List <int>();
                     }
                 }
                 else
                 {
                     channels = new List <int>();
                 }
             }
             catch
             {
                 return(BoxUtils.FormatErrorMsg("ntags分析错误"));
             }
         }
         else
         {
             channels = ListCache.Instance.Items[vkey].OrderArray;
         }
         var query = channels.Where(v =>
         {
             bool result = true;
             var video   = ListCache.Instance.Dictionary[v];
             foreach (var f in filters)
             {
                 result = result && f(video, pars, filter);
             }
             return(result);
         });
         return(CreatePageList(VideoSortUtils <VideoNode> .Sort(query, filter), filter, pars, false));
     }
     catch (KeyNotFoundException)
     {
         return(NoPlatForm());
     }
     catch (Exception ex)
     {
         return(BoxUtils.FormatErrorMsg(ex));
     }
 }