/// <summary> /// 获取节目信息扩展接口 /// </summary> public string LiveListsEx(LiveFilter filter) { try { var pars = VideoParsUtils.FormatLiveVideoPars(filter); var filters = VideoNodesUtil.FormateLiveVideoExFilter(filter, pars); var key = new VideoNodeKey(filter.platform, filter.type, filter.auth); var query = LiveListCache.Instance.Items[key].Where(v => { bool result = true; foreach (var f in filters) { result = result && f(v, pars, filter); } return(result); }); return(CreatePageList(VideoSortUtils <LiveVideoNode> .SortLiveVideos(query, filter, pars), filter, pars, key, true)); } catch (KeyNotFoundException) { return(NoPlatLive()); } catch (Exception ex) { return(BoxUtils.FormatErrorMsg(ex)); } }
/// <summary> /// 分页输出 /// </summary> private static string CreatePageList(IEnumerable <int> list, ListFilter filter, VideoPars pars, bool isEx) { if (filter.order != "s") { list = VideoSortUtils <VideoNode> .Sort(list, filter); } var xml = new XElement("vlist"); xml.Add(new XElement("countInPage", filter.c), new XElement("page", filter.s)); var count = list.PageList(filter, pars, xml, isEx); xml.AddFirst(new XElement("count", count), new XElement("page_count", PageUtils.PageCount(count, filter.c))); return(xml.ToString(SaveOptions.DisableFormatting)); }
/// <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)); } }