/// <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)); } }
private string LoadTree(TreeleftFilter filter, bool isEx) { try { var treeid = filter.treeleftid; if (treeid == 0) treeid = TreeNodeCache.Instance.Roots[filter.type]; TreeNode root; if (TreeNodeCache.Instance.Items.TryGetValue(treeid, out root)) { var key = new VideoNodeKey(filter.platform, filter.type, filter.auth); var xml = new XElement("tree"); RangTree(root, xml, filter, key, isEx); return xml.ToString(SaveOptions.DisableFormatting); } return NoPlatForm(); } catch (KeyNotFoundException) { return NoPlatForm(); } catch (Exception ex) { return BoxUtils.FormatErrorMsg(ex); } }
/// <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)); }
private string LoadTree(TreeleftFilter filter, bool isEx) { try { var treeid = filter.treeleftid; if (treeid == 0) { treeid = TreeNodeCache.Instance.Roots[filter.type]; } TreeNode root; if (TreeNodeCache.Instance.Items.TryGetValue(treeid, out root)) { var key = new VideoNodeKey(filter.platform, filter.type, filter.auth); var xml = new XElement("tree"); RangTree(root, xml, filter, key, isEx); return(xml.ToString(SaveOptions.DisableFormatting)); } return(NoPlatForm()); } catch (KeyNotFoundException) { return(NoPlatForm()); } catch (Exception ex) { return(BoxUtils.FormatErrorMsg(ex)); } }
public string ImageNavEx(CoverFilter filter) { try { var res = CoverNavCache.Instance.Items[filter.navmode]; var xml = new XElement("navs"); var key = new VideoNodeKey(filter.platform, 0, filter.auth); var filters = VideoNodesUtil.FormateTagFilter(filter); 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("count", count), new XElement("image", re.PicLink) )); return xml.ToString(SaveOptions.DisableFormatting); } catch (KeyNotFoundException) { return NoModeNav(); } catch (Exception ex) { return BoxUtils.FormatErrorMsg(ex); } }
/// <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) )); }
/// <summary> /// 单维度基本接口 /// </summary> public string VideoTags(TagsFilter filter) { try { var tags = TagCache.Instance.Items[new TagNodeKey() { Dimension = filter.dimension, Type = filter.type }]; var key = new VideoNodeKey(filter.platform, filter.type, filter.auth); var filters = VideoNodesUtil.CommonCustomFilter(filter); 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; } var xml = new XElement("tags", new XElement("info", BoxUtils.GetXmlCData(query.FormatListToStr(SplitArray.Line, 100))) ); return xml.ToString(SaveOptions.DisableFormatting); } catch (KeyNotFoundException) { return NoPlatForm(); } catch (Exception ex) { return BoxUtils.FormatErrorMsg(ex); } }
/// <summary> /// 单维度扩展接口 /// </summary> public string TagsEx(TagsFilter filter) { try { var tags = TagCache.Instance.Items[new TagNodeKey() { Dimension = filter.dimension, Type = filter.type }]; var key = new VideoNodeKey(filter.platform, filter.type, filter.auth); var xml = new XElement("tags"); var filters = VideoNodesUtil.FormateVodFilter(filter); xml.Add(from tag in tags where tag.Channels.ContainsKey(key) let count = GetChannelCount(tag, key, filter, filters) where count > 0 select new XElement("tag", new XElement("name", tag.Language[filter.lang].Title), new XElement("count", count) )); return(xml.ToString(SaveOptions.DisableFormatting)); } catch (KeyNotFoundException) { return(NoPlatForm()); } catch (Exception ex) { return(BoxUtils.FormatErrorMsg(ex)); } }
/// <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> public string TagsEx(TagsFilter filter) { try { var tags = TagCache.Instance.Items[new TagNodeKey() { Dimension = filter.dimension, Type = filter.type }]; var key = new VideoNodeKey(filter.platform, filter.type, filter.auth); var xml = new XElement("tags"); var filters = VideoNodesUtil.FormateVodFilter(filter); xml.Add(from tag in tags where tag.Channels.ContainsKey(key) let count = GetChannelCount(tag, key, filter, filters) where count > 0 select new XElement("tag", new XElement("name", tag.Language[filter.lang].Title), new XElement("count", count) )); return xml.ToString(SaveOptions.DisableFormatting); } catch (KeyNotFoundException) { return NoPlatForm(); } catch (Exception ex) { return BoxUtils.FormatErrorMsg(ex); } }
public string NavEx(NavFilter filter) { try { var res = RecommandCache.Instance.Items[filter.mode]; var xml = new XElement("navs"); var key = new VideoNodeKey(filter.platform, 0, filter.auth); var filters = VideoNodesUtil.FormateVodFilter(filter); 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("count", count), new XElement("image", re.PicLink) )); return(xml.ToString(SaveOptions.DisableFormatting)); } catch (KeyNotFoundException) { return(NoModeNav()); } catch (Exception ex) { return(BoxUtils.FormatErrorMsg(ex)); } }
public string NavLists(NavFilter filter) { try { var key = new VideoNodeKey(filter.platform, 0, filter.auth); var pars = VideoParsUtils.FormateSearchVideoPars(filter); var filters = VideoNodesUtil.FormateVodFilter(filter); var rel = RecommandCache.Instance.Dictionary[filter.navid]; var query = rel.Channels[key].Where(v => { bool result = true; var video = ListCache.Instance.Dictionary[v]; foreach (var f in filters) { result = result && f(video, filter); } return(result); }); return(CreatePageList(rel, query, filter, pars, false)); } catch (KeyNotFoundException) { return(NoPlatformNav()); } catch (Exception ex) { return(BoxUtils.FormatErrorMsg(ex)); } }
/// <summary> /// 直播分类信息扩展接口 /// </summary> public string LiveTypesEx(LiveFilter filter) { try { var key = new VideoNodeKey(filter.platform, filter.type, filter.auth); var root = new XElement("types"); var filters = VideoNodesUtil.FormateTagFilter(filter); 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("count", count), new XElement("image", livetype.PicLink) )); return root.ToString(SaveOptions.DisableFormatting); } catch (KeyNotFoundException) { return NoPlatLive(); } catch (Exception ex) { return BoxUtils.FormatErrorMsg(ex); } }
/// <summary> /// 直播分类信息扩展接口 /// </summary> public string LiveTypesEx(LiveFilter filter) { try { var key = new VideoNodeKey(filter.platform, filter.type, filter.auth); var root = new XElement("types"); var filters = VideoNodesUtil.FormateTagFilter(filter); 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("count", count), new XElement("image", livetype.PicLink) )); return(root.ToString(SaveOptions.DisableFormatting)); } catch (KeyNotFoundException) { return(NoPlatLive()); } catch (Exception ex) { return(BoxUtils.FormatErrorMsg(ex)); } }
private int GetAllChannelCount(TreeNode node, VideoNodeKey key) { if (node.AllChannels.ContainsKey(key)) { return(node.AllChannels[key].Count); } return(0); }
private void LoadAllChannel(TreeNode node, VideoNodeKey key, int count, int channelId) { if (!node.AllChannels.ContainsKey(key)) { node.AllChannels[key] = new List <int>(100); } node.AllChannels[key].Add(channelId); }
/// <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> public static LuceneResultNode RelevanceSearch(RelevanceFilter filter, string query, int maxHit) { var fkey = new VideoNodeKey(filter.platform, 0, filter.auth); var containfilters = new List <ContainFilterNode>(); var fbname = string.Empty; if (filter.forbidden) { filter.forbidden = VideoNodeKeyArray.Instance.Forbidden[fkey]; if (filter.forbidden) { if (ForbiddenAreaCache.Instance.Items.ContainsKey(filter.fbcode)) { fbname = ForbiddenAreaCache.Instance.Items[filter.fbcode].ForbiddenAreaName; } else { filter.forbidden = false; } } } if (filter.forbidden) { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.ForbiddenCode, Text = fbname.ToLower() }); } var pindx = VideoNodeKeyArray.Instance.Items[fkey].ToString(); containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.PlatformIndex, Text = pindx }); if (filter.ver > 1 && filter.screen != "v") { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.Screen, Text = "0" }); } var node = new SearchNode(); node.Key = filter.vids; node.Pindex = pindx; node.Queries = query;//Searcher.SegmentKeyWord(filter.k); node.Fields = EpgIndexNode.RelevanceFields; node.Occurs = EpgIndexNode.RelevanceOccurs; node.ContainFilters = containfilters; node.Start = 1; node.Limit = maxHit; node.IndexValue = EpgIndexNode.IndexValue; return(Searcher.SearchMaxHit(EpgLuceneNet.Instance.IndexDic, node, maxHit)); }
public void ForbiddenInit() { var plats = PlatformUtils.FormatVodPlatform(); var fb = new Dictionary<VideoNodeKey, bool>(plats.Count); foreach (var f in plats) { var key = new VideoNodeKey(f.PlatformName, 0, f.Licence); fb.Add(key, f.IsForbiddenSupport); } _forbidden = fb; }
/// <summary> /// LuceneNet分页输出 /// </summary> private string CreateSmarkPageList(LuceneResultNode result, LiveSearchFilter filter, bool isEx) { var key = new VideoNodeKey(filter.platform, 0, filter.auth); var xml = new XElement("vlist"); xml.Add(new XElement("count", result.AllCount)); xml.Add(new XElement("page_count", PageUtils.PageCount(result.AllCount, filter.c))); xml.Add(new XElement("countInPage", filter.c)); xml.Add(new XElement("page", filter.s)); xml.Add(from v in result.Result select VideoResponseUtils.CustomLiveListRes(LiveListCache.Instance.Dictionary[int.Parse(v)], filter, 0, isEx)); return(xml.ToString(SaveOptions.DisableFormatting)); }
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)); } }
public override void RefreshCache() { var livetypes = LiveTypeCache.Instance.Items; var list = new List <LiveTypeNode>(livetypes.Count); var types = from livetype in livetypes join rel in ChannelLiveRelCache.Instance.Items on livetype.ID equals rel.LiveTypeID into rels select new { Type = livetype, Rels = rels.OrderBy(r => r.Rank) }; foreach (var type in types) { var count = type.Rels.Count(); if (count <= 0) { continue; } var node = new LiveTypeNode() { Language = SimpleLanguageHandler.ProcessLang(type.Type.TypeName, type.Type.TypeNameEng), PicLink = type.Type.PicLink, ID = type.Type.ID, Channels = new Dictionary <VideoNodeKey, List <int> >(PlatformUtils.FormatVodPlatform().Count) }; foreach (var rel in type.Rels) { LiveVideoNode v; if (LiveListCache.Instance.Dictionary.TryGetValue(rel.ChannelID, out v)) { foreach (var plat in v.PlatForms) { var vk = new VideoNodeKey(plat.PlatformName, 0, plat.Licence); if (!node.Channels.ContainsKey(vk)) { node.Channels.Add(vk, new List <int>(count)); } node.Channels[vk].Add(v.Main.ChannelID); } } } list.Add(node); } _cache = list; }
/// <summary> /// 广度优先遍历树 /// </summary> private void RangTree(TreeNode root, XElement xml, TreeleftFilter filter, VideoNodeKey key,bool isEx) { var queue = new Queue<TreeNode>(root.Childrens.Count * filter.rank); var depth = root.Depth + filter.rank; var isex = isEx; queue.Enqueue(root); while (queue.Count > 0) { var node = queue.Dequeue(); foreach (var child in node.Childrens) { var childnode = TreeNodeCache.Instance.Items[child]; if (childnode.Depth < depth) queue.Enqueue(childnode); ResponseXml(childnode, xml, filter, key, isex); } } }
/// <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)); } }
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); } }
private int GetChannelCount(TagNode node, VideoNodeKey key, TagsFilter filter, List <Func <VideoBase, ExFilterBase, bool> > filters) { int count = 0; var cs = node.Channels[key]; foreach (var c in cs) { var result = true; var v = ListCache.Instance.Dictionary[c]; foreach (var f in filters) { result = result && f(v, filter); } if (result) { count++; } } return(count); }
/// <summary> /// 广度优先遍历树 /// </summary> private void RangTree(TreeNode root, XElement xml, TreeleftFilter filter, VideoNodeKey key, bool isEx) { var queue = new Queue <TreeNode>(root.Childrens.Count * filter.rank); var depth = root.Depth + filter.rank; var isex = isEx; queue.Enqueue(root); while (queue.Count > 0) { var node = queue.Dequeue(); foreach (var child in node.Childrens) { var childnode = TreeNodeCache.Instance.Items[child]; if (childnode.Depth < depth) { queue.Enqueue(childnode); } ResponseXml(childnode, xml, filter, key, isex); } } }
private int GetAllChannelExCount(TreeNode node, VideoNodeKey key, List <Func <VideoBase, ExFilterBase, bool> > filters, TreeleftFilter filter) { int count = 0; if (node.AllChannels.ContainsKey(key)) { var cs = node.AllChannels[key]; foreach (var c in cs) { var result = true; foreach (var f in filters) { result = result && f(ListCache.Instance.Dictionary[c], filter); } if (result) { count++; } } } return(count); }
public string ImageNav(CoverFilter filter) { try { var res = CoverNavCache.Instance.Items[filter.navmode]; 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)); } }
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); } }
public void Init() { if (_inited) return; var types = BoxTypeCache.Instance.Items.Values; var plats = PlatformUtils.FormatVodPlatform(); var list = new Dictionary<VideoNodeKey, int>(types.Count * plats.Count + 1); var fb = new Dictionary<VideoNodeKey, bool>(plats.Count); int i = 0; foreach (var f in plats) { var key = new VideoNodeKey(f.PlatformName, 0, f.Licence); fb.Add(key, f.IsForbiddenSupport); list.Add(key, ++i); foreach (var type in types) { list.Add(new VideoNodeKey(f.PlatformName, type.TypeID, f.Licence), ++i); } } list.Add(new VideoNodeKey(AuthNode.NoPlatFormName, 0, AuthNode.NoPlatFormLicence), ++i); _list = list; _forbidden = fb; _inited = true; }
/// <summary> /// LuceneNet节目预告分页输出 /// </summary> private string CreateParadeSmarkPageList(LuceneResultNode result, LiveSearchFilter filter, bool isEx) { var vkey = new VideoNodeKey(filter.platform, 0, filter.auth); var parades = from parade in result.Result select ChannelLiveItemsCache.Instance.Items[int.Parse(parade)]; var query = from parade in parades group parade by parade.ChannelID; var list = query.ToList(); //var groupquery = query.Skip(filter.c * (filter.s - 1)).Take(filter.c); //var count = groupquery.Count(); var index = (filter.s - 1) * filter.c; var max = index + filter.c; if (max > list.Count) { max = list.Count; } var count = max - index; var xml = new XElement("vlist"); xml.Add(new XElement("count", count)); xml.Add(new XElement("page_count", PageUtils.PageCount(count, filter.c))); xml.Add(new XElement("countInPage", filter.c)); xml.Add(new XElement("page", filter.s)); for (var i = index; i < max; i++) { var group = list[i]; var v = VideoResponseUtils.CustomLiveListRes(LiveListCache.Instance.Dictionary[group.Key], filter, 0, isEx); var paraderoot = new XElement("parade_list"); foreach (var key in group) { paraderoot.Add(VideoResponseUtils.LiveListSearchParade(key, filter)); } v.Add(paraderoot); xml.Add(v); } return(xml.ToString(SaveOptions.DisableFormatting)); }
/// <summary> /// 多维度扩展接口 /// </summary> public string MultiTagsEx(TagsFilter filter) { try { var dimensions = filter.dimension.Split(SplitArray.LineArray, StringSplitOptions.RemoveEmptyEntries).Distinct(); 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); var dimensionxml = new XElement("dimension", new XAttribute("name", dimension)); var filters = VideoNodesUtil.FormateVodFilter(filter); dimensionxml.Add(from tag in tags where tag.Channels.ContainsKey(key) let count = GetChannelCount(tag, key, filter, filters) where count > 0 select new XElement("tag", new XElement("name", tag.Language[filter.lang].Title), new XElement("count", count) )); xml.Add(dimensionxml); } return(xml.ToString(SaveOptions.DisableFormatting)); } catch (KeyNotFoundException) { return(NoPlatForm()); } catch (Exception ex) { return(BoxUtils.FormatErrorMsg(ex)); } }
/// <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(IEnumerable<LiveVideoNode> list, LiveFilter filter, VideoPars pars, VideoNodeKey key, bool isEx) { 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> /// LuceneNet节目预告分页输出 /// </summary> private string CreateParadeSmarkPageList(LuceneResultNode result, LiveSearchFilter filter, bool isEx) { var vkey = new VideoNodeKey(filter.platform, 0, filter.auth); var parades = from parade in result.Result select ChannelLiveItemsCache.Instance.Items[int.Parse(parade)]; var query = from parade in parades group parade by parade.ChannelID; var list = query.ToList(); //var groupquery = query.Skip(filter.c * (filter.s - 1)).Take(filter.c); //var count = groupquery.Count(); var index = (filter.s - 1) * filter.c; var max = index + filter.c; if (max > list.Count) max = list.Count; var count = max - index; var xml = new XElement("vlist"); xml.Add(new XElement("count", count)); xml.Add(new XElement("page_count", PageUtils.PageCount(count, filter.c))); xml.Add(new XElement("countInPage", filter.c)); xml.Add(new XElement("page", filter.s)); for (var i = index; i < max; i++) { var group = list[i]; var v = VideoResponseUtils.CustomLiveListRes(LiveListCache.Instance.Dictionary[group.Key], filter, 0, isEx); var paraderoot = new XElement("parade_list"); foreach (var key in group) { paraderoot.Add(VideoResponseUtils.LiveListSearchParade(key, filter)); } v.Add(paraderoot); xml.Add(v); } return xml.ToString(SaveOptions.DisableFormatting); }
/// <summary> /// 直播扩展搜索 /// </summary> public static LuceneResultNode LiveSearchEx(LiveSearchFilter filter, string[] searchFields, string query, bool isNoPaging) { var fkey = new VideoNodeKey(filter.platform, 0, filter.auth); var containfilters = new List <ContainFilterNode>(); var fbname = string.Empty; if (filter.forbidden) { filter.forbidden = VideoNodeKeyArray.Instance.Forbidden[fkey]; if (filter.forbidden) { if (ForbiddenAreaCache.Instance.Items.ContainsKey(filter.fbcode)) { fbname = ForbiddenAreaCache.Instance.Items[filter.fbcode].ForbiddenAreaName; } else { filter.forbidden = false; } } } if (filter.forbidden) { containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.ForbiddenCode, Text = fbname.ToLower() }); } var pindx = VideoNodeKeyArray.Instance.Items[fkey].ToString(); containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.PlatformIndex, Text = pindx }); if (!string.IsNullOrEmpty(filter.flag)) { containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.Flags, Text = VideoParsUtils.OrderAscFlags(filter.flag) }); } if (filter.ver <= 1) { containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.TableType, Text = "0" }); } else { containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.IsGroup, Text = "0" }); } if (filter.forbidvip == 1) { containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.VipFlag, Text = "0" }); } List <LongRangeNode> longs = new List <LongRangeNode>(); if (filter.lastday != 0) { longs.Add(new LongRangeNode() { FieldName = LiveEpgNode.ParadeBeginTime, MinValue = 0, MaxValue = filter.lastday }); } List <NumberRangeNode> rangenodes = new List <NumberRangeNode>(); if (filter.bitratemin != 0 || filter.bitratemax != 0) { if (filter.bitratemax == 0) { filter.bitratemax = int.MaxValue; } rangenodes.Add(new NumberRangeNode() { FieldName = LiveEpgNode.BitrateRange, MinValue = filter.bitratemin, MaxValue = filter.bitratemax }); } if (filter.hmin != 0 || filter.hmax != 0) { if (filter.hmax == 0) { filter.hmax = int.MaxValue; } rangenodes.Add(new NumberRangeNode() { FieldName = LiveEpgNode.HightRange, MinValue = filter.hmin, MaxValue = filter.hmax }); } if (filter.wmin != 0 || filter.wmax != 0) { if (filter.wmax == 0) { filter.wmax = int.MaxValue; } rangenodes.Add(new NumberRangeNode() { FieldName = LiveEpgNode.WidthRange, MinValue = filter.wmin, MaxValue = filter.wmax }); } SearchNode node = new SearchNode(); node.Key = filter.k; node.Pindex = pindx; node.Queries = query;//Searcher.SegmentKeyWord(filter.k); node.Fields = searchFields; node.Occurs = LiveEpgNode.Occurs; node.LongRnageFilters = longs; node.ContainFilters = containfilters; node.NumberRangeFiters = rangenodes; node.Start = filter.s; node.Limit = filter.c; node.IsNoPaging = isNoPaging; node.IndexValue = LiveEpgNode.IndexValue; return(Searcher.SearchEx(LiveEpgLuceneNet.Instance.IndexDic, node)); }
/// <summary> /// 点播基本搜索 /// </summary> public static LuceneResultNode Search(ListFilter filter, string[] fields, Lucene.Net.Search.BooleanClause.Occur[] occurs, string query, bool isStat) { var fkey = new VideoNodeKey(filter.platform, 0, filter.auth); var containfilters = new List<ContainFilterNode>(); var fbname = string.Empty; if (filter.forbidden) { filter.forbidden = VideoNodeKeyArray.Instance.Forbidden[fkey]; if (filter.forbidden) { if (ForbiddenAreaCache.Instance.Items.ContainsKey(filter.fbcode)) { fbname = ForbiddenAreaCache.Instance.Items[filter.fbcode].ForbiddenAreaName; } else { filter.forbidden = false; } } } if (filter.forbidden) { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.ForbiddenCode, Text = fbname.ToLower() }); } var pindx = VideoNodeKeyArray.Instance.Items[fkey].ToString(); containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.PlatformIndex, Text = pindx }); if (!string.IsNullOrEmpty(filter.flag)) { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.Flags, Text = VideoParsUtils.OrderAscFlags(filter.flag) }); } if (filter.ver <= 1) { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.TableType, Text = "0" }); } else { if (filter.screen == "v") { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.IsGroup, Text = "0" }); } else { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.Screen, Text = "0" }); containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.IsGroup, Text = "0" }); } } //if (filter.type != 0) //{ // containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.Type, Text = filter.type.ToString() }); //} var node = new SearchNode(); node.Key = filter.k; node.Pindex = pindx; node.Queries = query;//Searcher.SegmentKeyWord(filter.k); node.Fields = fields; node.Occurs = occurs; //node.SortFields = EpgIndexNode.SortFields; node.ContainFilters = containfilters; node.LongRnageFilters = new List<LongRangeNode>(); node.Start = filter.s; node.Limit = filter.c; node.IndexValue = EpgIndexNode.IndexValue; node.IsStat = isStat; node.VodType = filter.type; node.ShowNav = filter.shownav; node.TotalTypes = BoxTypeCache.Instance.Items.Count; return Searcher.Search(EpgLuceneNet.Instance.IndexDic, node); }
public string NavLists(NavFilter filter) { try { var key = new VideoNodeKey(filter.platform, 0, filter.auth); var pars = VideoParsUtils.FormateSearchVideoPars(filter); var filters = VideoNodesUtil.FormateVodFilter(filter); var rel = RecommandCache.Instance.Dictionary[filter.navid]; var query = rel.Channels[key].Where(v => { bool result = true; var video = ListCache.Instance.Dictionary[v]; foreach (var f in filters) { result = result && f(video, filter); } return result; }); return CreatePageList(rel, query, filter, pars, false); } catch (KeyNotFoundException) { return NoPlatformNav(); } catch (Exception ex) { return BoxUtils.FormatErrorMsg(ex); } }
/// <summary> /// 直播扩展搜索 /// </summary> public static LuceneResultNode LiveSearchEx(LiveSearchFilter filter, string[] searchFields, string query, bool isNoPaging) { var fkey = new VideoNodeKey(filter.platform, 0, filter.auth); var containfilters = new List<ContainFilterNode>(); var fbname = string.Empty; if (filter.forbidden) { filter.forbidden = VideoNodeKeyArray.Instance.Forbidden[fkey]; if (filter.forbidden) { if (ForbiddenAreaCache.Instance.Items.ContainsKey(filter.fbcode)) { fbname = ForbiddenAreaCache.Instance.Items[filter.fbcode].ForbiddenAreaName; } else { filter.forbidden = false; } } } if (filter.forbidden) { containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.ForbiddenCode, Text = fbname.ToLower() }); } var pindx = VideoNodeKeyArray.Instance.Items[fkey].ToString(); containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.PlatformIndex, Text = pindx }); if (!string.IsNullOrEmpty(filter.flag)) { containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.Flags, Text = VideoParsUtils.OrderAscFlags(filter.flag) }); } if (filter.ver <= 1) { containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.TableType, Text = "0" }); } else { containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.IsGroup, Text = "0" }); } if (filter.forbidvip == 1) { containfilters.Add(new ContainFilterNode() { FieldName = LiveEpgNode.VipFlag, Text = "0" }); } List<LongRangeNode> longs = new List<LongRangeNode>(); if (filter.lastday != 0) { longs.Add(new LongRangeNode() { FieldName = LiveEpgNode.ParadeBeginTime, MinValue = 0, MaxValue = filter.lastday }); } List<NumberRangeNode> rangenodes = new List<NumberRangeNode>(); if (filter.bitratemin != 0 || filter.bitratemax != 0) { if (filter.bitratemax == 0) filter.bitratemax = int.MaxValue; rangenodes.Add(new NumberRangeNode() { FieldName = LiveEpgNode.BitrateRange, MinValue = filter.bitratemin, MaxValue = filter.bitratemax }); } if (filter.hmin != 0 || filter.hmax != 0) { if (filter.hmax == 0) filter.hmax = int.MaxValue; rangenodes.Add(new NumberRangeNode() { FieldName = LiveEpgNode.HightRange, MinValue = filter.hmin, MaxValue = filter.hmax }); } if (filter.wmin != 0 || filter.wmax != 0) { if (filter.wmax == 0) filter.wmax = int.MaxValue; rangenodes.Add(new NumberRangeNode() { FieldName = LiveEpgNode.WidthRange, MinValue = filter.wmin, MaxValue = filter.wmax }); } SearchNode node = new SearchNode(); node.Key = filter.k; node.Pindex = pindx; node.Queries = query;//Searcher.SegmentKeyWord(filter.k); node.Fields = searchFields; node.Occurs = LiveEpgNode.Occurs; node.LongRnageFilters = longs; node.ContainFilters = containfilters; node.NumberRangeFiters = rangenodes; node.Start = filter.s; node.Limit = filter.c; node.IsNoPaging = isNoPaging; node.IndexValue = LiveEpgNode.IndexValue; return Searcher.SearchEx(LiveEpgLuceneNet.Instance.IndexDic, node); }
/// <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)); } }
/// <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); }
/// <summary> /// 点播基本搜索 /// </summary> public static LuceneResultNode Search(ListFilter filter, string[] fields, Lucene.Net.Search.BooleanClause.Occur[] occurs, string query, bool isStat) { var fkey = new VideoNodeKey(filter.platform, 0, filter.auth); var containfilters = new List <ContainFilterNode>(); var fbname = string.Empty; if (filter.forbidden) { filter.forbidden = VideoNodeKeyArray.Instance.Forbidden[fkey]; if (filter.forbidden) { if (ForbiddenAreaCache.Instance.Items.ContainsKey(filter.fbcode)) { fbname = ForbiddenAreaCache.Instance.Items[filter.fbcode].ForbiddenAreaName; } else { filter.forbidden = false; } } } if (filter.forbidden) { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.ForbiddenCode, Text = fbname.ToLower() }); } var pindx = VideoNodeKeyArray.Instance.Items[fkey].ToString(); containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.PlatformIndex, Text = pindx }); if (!string.IsNullOrEmpty(filter.flag)) { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.Flags, Text = VideoParsUtils.OrderAscFlags(filter.flag) }); } if (filter.ver <= 1) { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.TableType, Text = "0" }); } else { if (filter.screen == "v") { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.IsGroup, Text = "0" }); } else { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.Screen, Text = "0" }); containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.IsGroup, Text = "0" }); } } //if (filter.type != 0) //{ // containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.Type, Text = filter.type.ToString() }); //} var node = new SearchNode(); node.Key = filter.k; node.Pindex = pindx; node.Queries = query;//Searcher.SegmentKeyWord(filter.k); node.Fields = fields; node.Occurs = occurs; //node.SortFields = EpgIndexNode.SortFields; node.ContainFilters = containfilters; node.LongRnageFilters = new List <LongRangeNode>(); node.Start = filter.s; node.Limit = filter.c; node.IndexValue = EpgIndexNode.IndexValue; node.IsStat = isStat; node.VodType = filter.type; node.ShowNav = filter.shownav; node.TotalTypes = BoxTypeCache.Instance.Items.Count; return(Searcher.Search(EpgLuceneNet.Instance.IndexDic, node)); }
/// <summary> /// 点播扩展关联推荐 /// </summary> public static LuceneResultNode RelevanceSearchEx(RelevanceFilter filter, string query, int maxHit) { var fkey = new VideoNodeKey(filter.platform, 0, filter.auth); var rangenodes = new List<NumberRangeNode>(); var containfilters = new List<ContainFilterNode>(); var fbname = string.Empty; if (filter.forbidden) { filter.forbidden = VideoNodeKeyArray.Instance.Forbidden[fkey]; if (filter.forbidden) { if (ForbiddenAreaCache.Instance.Items.ContainsKey(filter.fbcode)) { fbname = ForbiddenAreaCache.Instance.Items[filter.fbcode].ForbiddenAreaName; } else { filter.forbidden = false; } } } if (filter.forbidden) { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.ForbiddenCode, Text = fbname.ToLower() }); } var pindx = VideoNodeKeyArray.Instance.Items[fkey].ToString(); containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.PlatformIndex, Text = pindx }); if (filter.bitratemin != 0 || filter.bitratemax != 0) { if (filter.bitratemax == 0) filter.bitratemax = int.MaxValue; rangenodes.Add(new NumberRangeNode() { FieldName = EpgIndexNode.BitrateRange, MinValue = filter.bitratemin, MaxValue = filter.bitratemax }); } if (filter.hmin != 0 || filter.hmax != 0) { if (filter.hmax == 0) filter.hmax = int.MaxValue; rangenodes.Add(new NumberRangeNode() { FieldName = EpgIndexNode.HightRange, MinValue = filter.hmin, MaxValue = filter.hmax }); } if (filter.wmin != 0 || filter.wmax != 0) { if (filter.wmax == 0) filter.wmax = int.MaxValue; rangenodes.Add(new NumberRangeNode() { FieldName = EpgIndexNode.WidthRange, MinValue = filter.wmin, MaxValue = filter.wmax }); } if (filter.forbidvip == 1) { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.VipFlag, Text = "0" }); } if (filter.ver > 1 && filter.screen != "v") { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.Screen, Text = "0" }); } var node = new SearchNode(); node.Key = filter.vids; node.Pindex = pindx; node.Queries = query;//Searcher.SegmentKeyWord(filter.k); node.Fields = EpgIndexNode.RelevanceFields; node.Occurs = EpgIndexNode.RelevanceOccurs; //node.SortFields = EpgIndexNode.SortFields; node.ContainFilters = containfilters; node.NumberRangeFiters = rangenodes; node.Start = 1; node.Limit = maxHit; node.IndexValue = EpgIndexNode.IndexValue; return Searcher.SearchMaxHitEx(EpgLuceneNet.Instance.IndexDic, node, maxHit); }
/// <summary> /// 点播扩展关联推荐 /// </summary> public static LuceneResultNode RelevanceSearchEx(RelevanceFilter filter, string query, int maxHit) { var fkey = new VideoNodeKey(filter.platform, 0, filter.auth); var rangenodes = new List <NumberRangeNode>(); var containfilters = new List <ContainFilterNode>(); var fbname = string.Empty; if (filter.forbidden) { filter.forbidden = VideoNodeKeyArray.Instance.Forbidden[fkey]; if (filter.forbidden) { if (ForbiddenAreaCache.Instance.Items.ContainsKey(filter.fbcode)) { fbname = ForbiddenAreaCache.Instance.Items[filter.fbcode].ForbiddenAreaName; } else { filter.forbidden = false; } } } if (filter.forbidden) { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.ForbiddenCode, Text = fbname.ToLower() }); } var pindx = VideoNodeKeyArray.Instance.Items[fkey].ToString(); containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.PlatformIndex, Text = pindx }); if (filter.bitratemin != 0 || filter.bitratemax != 0) { if (filter.bitratemax == 0) { filter.bitratemax = int.MaxValue; } rangenodes.Add(new NumberRangeNode() { FieldName = EpgIndexNode.BitrateRange, MinValue = filter.bitratemin, MaxValue = filter.bitratemax }); } if (filter.hmin != 0 || filter.hmax != 0) { if (filter.hmax == 0) { filter.hmax = int.MaxValue; } rangenodes.Add(new NumberRangeNode() { FieldName = EpgIndexNode.HightRange, MinValue = filter.hmin, MaxValue = filter.hmax }); } if (filter.wmin != 0 || filter.wmax != 0) { if (filter.wmax == 0) { filter.wmax = int.MaxValue; } rangenodes.Add(new NumberRangeNode() { FieldName = EpgIndexNode.WidthRange, MinValue = filter.wmin, MaxValue = filter.wmax }); } if (filter.forbidvip == 1) { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.VipFlag, Text = "0" }); } if (filter.ver > 1 && filter.screen != "v") { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.Screen, Text = "0" }); } var node = new SearchNode(); node.Key = filter.vids; node.Pindex = pindx; node.Queries = query;//Searcher.SegmentKeyWord(filter.k); node.Fields = EpgIndexNode.RelevanceFields; node.Occurs = EpgIndexNode.RelevanceOccurs; //node.SortFields = EpgIndexNode.SortFields; node.ContainFilters = containfilters; node.NumberRangeFiters = rangenodes; node.Start = 1; node.Limit = maxHit; node.IndexValue = EpgIndexNode.IndexValue; return(Searcher.SearchMaxHitEx(EpgLuceneNet.Instance.IndexDic, node, maxHit)); }
/// <summary> /// 多维度扩展接口 /// </summary> public string MultiTagsEx(TagsFilter filter) { try { var dimensions = filter.dimension.Split(SplitArray.LineArray, StringSplitOptions.RemoveEmptyEntries).Distinct(); 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); var dimensionxml = new XElement("dimension", new XAttribute("name", dimension)); var filters = VideoNodesUtil.FormateVodFilter(filter); dimensionxml.Add(from tag in tags where tag.Channels.ContainsKey(key) let count = GetChannelCount(tag, key, filter, filters) where count > 0 select new XElement("tag", new XElement("name", tag.Language[filter.lang].Title), new XElement("count", count) )); xml.Add(dimensionxml); } return xml.ToString(SaveOptions.DisableFormatting); } catch (KeyNotFoundException) { return NoPlatForm(); } catch (Exception ex) { return BoxUtils.FormatErrorMsg(ex); } }
/// <summary> /// LuceneNet分页输出 /// </summary> private string CreateSmarkPageList(LuceneResultNode result, LiveSearchFilter filter, bool isEx) { var key = new VideoNodeKey(filter.platform, 0, filter.auth); var xml = new XElement("vlist"); xml.Add(new XElement("count", result.AllCount)); xml.Add(new XElement("page_count", PageUtils.PageCount(result.AllCount, filter.c))); xml.Add(new XElement("countInPage", filter.c)); xml.Add(new XElement("page", filter.s)); xml.Add(from v in result.Result select VideoResponseUtils.CustomLiveListRes(LiveListCache.Instance.Dictionary[int.Parse(v)], filter, 0, isEx)); 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; }
private int GetChannelCount(TagNode node, VideoNodeKey key, TagsFilter filter, List<Func<VideoBase, ExFilterBase, bool>> filters) { int count = 0; var cs = node.Channels[key]; foreach (var c in cs) { var result = true; var v = ListCache.Instance.Dictionary[c]; foreach (var f in filters) { result = result && f(v, filter); } if (result) count++; } return count; }
private int GetAllChannelExCount(TreeNode node, VideoNodeKey key, List<Func<VideoBase, ExFilterBase, bool>> filters, TreeleftFilter filter) { int count = 0; if (node.AllChannels.ContainsKey(key)) { var cs = node.AllChannels[key]; foreach (var c in cs) { var result = true; foreach (var f in filters) { result = result && f(ListCache.Instance.Dictionary[c], filter); } if (result) count++; } } return count; }
private int GetAllChannelCount(TreeNode node, VideoNodeKey key) { if (node.AllChannels.ContainsKey(key)) return node.AllChannels[key].Count; return 0; }
/// <summary> /// 点播关联推荐 /// </summary> public static LuceneResultNode RelevanceSearch(RelevanceFilter filter, string query, int maxHit) { var fkey = new VideoNodeKey(filter.platform, 0, filter.auth); var containfilters = new List<ContainFilterNode>(); var fbname = string.Empty; if (filter.forbidden) { filter.forbidden = VideoNodeKeyArray.Instance.Forbidden[fkey]; if (filter.forbidden) { if (ForbiddenAreaCache.Instance.Items.ContainsKey(filter.fbcode)) { fbname = ForbiddenAreaCache.Instance.Items[filter.fbcode].ForbiddenAreaName; } else { filter.forbidden = false; } } } if (filter.forbidden) { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.ForbiddenCode, Text = fbname.ToLower() }); } var pindx = VideoNodeKeyArray.Instance.Items[fkey].ToString(); containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.PlatformIndex, Text = pindx }); if (filter.ver > 1 && filter.screen != "v") { containfilters.Add(new ContainFilterNode() { FieldName = EpgIndexNode.Screen, Text = "0" }); } var node = new SearchNode(); node.Key = filter.vids; node.Pindex = pindx; node.Queries = query;//Searcher.SegmentKeyWord(filter.k); node.Fields = EpgIndexNode.RelevanceFields; node.Occurs = EpgIndexNode.RelevanceOccurs; node.ContainFilters = containfilters; node.Start = 1; node.Limit = maxHit; node.IndexValue = EpgIndexNode.IndexValue; return Searcher.SearchMaxHit(EpgLuceneNet.Instance.IndexDic, node, maxHit); }
/// <summary> /// 分页输出频道列表 /// </summary> private string CreatePageList(IEnumerable <LiveVideoNode> list, LiveFilter filter, VideoPars pars, VideoNodeKey key, bool isEx) { 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 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); } }
private void ParentLoadChannel(Dictionary <int, TreeNode> dic, TreeNode node, VideoNodeKey key, int count, int channelId) { //LoadAllChannel(node, key, count, channelId); var cnode = node; while (cnode.Node.ParentNodeID != 0) { var pnode = dic[cnode.Node.ParentNodeID]; cnode = pnode; LoadAllChannel(cnode, key, count, channelId); } }