/// <summary> /// 得到该推荐分类下的频道数 /// </summary> private int GetChannelCount(CoverNavNode node, VideoNodeKey key, CoverFilter filter, List <Func <VideoBase, ExFilterBase, bool> > filters) { int count = 0; if (node.Images.ContainsKey(key)) { var images = node.Images[key]; foreach (var image in images) { var c = CoverImageCache.Instance.Items[image]; var result = true; VideoBase v = null; if (c.ChannelType == 3) { v = ListCache.Instance.Dictionary[c.ChannelId]; } else { v = LiveListCache.Instance.Dictionary[c.ChannelId]; } foreach (var f in filters) { result = result && f(v, filter); } if (result) { count++; } } } return(count); }
/// <summary> /// 分页输出 /// </summary> private string CreatePageList(CoverNavNode node, CoverFilter filter, VideoPars pars, List <Func <VideoBase, ExFilterBase, bool> > filters, bool isEx) { var key = new VideoNodeKey(filter.platform, 0, filter.auth); var xml = new XElement("cover_list"); int all = 0; var images = node.Images[key]; for (var i = 0; i < images.Count && all < filter.c; i++) { var image = CoverImageCache.Instance.Items[images[i]]; bool result = true; VideoBase video = null; if (image.ChannelType == 3) { video = ListCache.Instance.Dictionary[image.ChannelId]; } else { video = LiveListCache.Instance.Dictionary[image.ChannelId]; } foreach (var f in filters) { result = result && f(video, filter); } if (!result) { continue; } all++; XElement playlink; if (image.ChannelType == 3) { playlink = VideoResponseUtils.CreateVodPlayLinkVer2(image.ChannelId, filter, isEx); } else { playlink = VideoResponseUtils.CreateLivePlayLinkVer2(image.ChannelId, filter, isEx); } var subttitle = image.Language[filter.lang].SubTitle; if (filter.conlen != 0) { subttitle = subttitle.FormateSubStr(filter.conlen); } xml.Add(new XElement("c", new XElement("title", image.Language[filter.lang].Title), new XElement("note", subttitle), new XElement("vid", image.ChannelId), new XElement("vtype", image.ChannelType == 3 ? "vod" : "live"), playlink, new XElement("cover_imgurl", image.ImageUrl), new XElement("onlinetime", image.OnlineTime.ToString("yyyy-MM-dd HH:mm:ss")) )); } return(xml.ToString(SaveOptions.DisableFormatting)); }
/// <summary> /// 分页输出 /// </summary> private string CreatePageList(CoverNavNode node, CoverFilter filter, VideoPars pars, List<Func<VideoBase, ExFilterBase, bool>> filters, bool isEx) { var key = new VideoNodeKey(filter.platform, 0, filter.auth); var xml = new XElement("cover_list"); int all = 0; var images = node.Images[key]; for (var i = 0; i < images.Count && all < filter.c; i++) { var image = CoverImageCache.Instance.Items[images[i]]; bool result = true; VideoBase video = null; if (image.ChannelType == 3) video = ListCache.Instance.Dictionary[image.ChannelId]; else video = LiveListCache.Instance.Dictionary[image.ChannelId]; foreach (var f in filters) { result = result && f(video, filter); } if (!result) continue; all++; XElement playlink; if (image.ChannelType == 3) playlink = VideoResponseUtils.CreateVodPlayLinkVer2(image.ChannelId, filter, isEx); else playlink = VideoResponseUtils.CreateLivePlayLinkVer2(image.ChannelId, filter, isEx); var subttitle = image.Language[filter.lang].SubTitle; if (filter.conlen != 0) subttitle = subttitle.FormateSubStr(filter.conlen); xml.Add(new XElement("c", new XElement("title", image.Language[filter.lang].Title), new XElement("note", subttitle), new XElement("vid", image.ChannelId), new XElement("vtype", image.ChannelType == 3 ? "vod" : "live"), playlink, new XElement("cover_imgurl", image.ImageUrl), new XElement("onlinetime", image.OnlineTime.ToString("yyyy-MM-dd HH:mm:ss")) )); } return xml.ToString(SaveOptions.DisableFormatting); }
/// <summary> /// 得到该推荐分类下的频道数 /// </summary> private int GetChannelCount(CoverNavNode node, VideoNodeKey key, CoverFilter filter, List<Func<VideoBase, ExFilterBase, bool>> filters) { int count = 0; if (node.Images.ContainsKey(key)) { var images = node.Images[key]; foreach (var image in images) { var c = CoverImageCache.Instance.Items[image]; var result = true; VideoBase v = null; if (c.ChannelType == 3) v = ListCache.Instance.Dictionary[c.ChannelId]; else v = LiveListCache.Instance.Dictionary[c.ChannelId]; foreach (var f in filters) { result = result && f(v, filter); } if (result) count++; } } return count; }