Exemplo n.º 1
0
 /// <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));
     }
 }
Exemplo n.º 2
0
 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));
     }
 }
Exemplo n.º 3
0
 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));
     }
 }
Exemplo n.º 4
0
        //#region ICover Members

        //public string ImageRecommand(CoverFilter filter)
        //{
        //    try
        //    {
        //        var images = ConverImageCache.Instance.Items;
        //        int all = 0;
        //        var xml = new XElement("cover_list");
        //        var vkey = new VideoNodeKey(filter.platform, 0, filter.auth);
        //        var filters = VideoNodesUtil.CommonCustomFilter(filter);
        //        for (var i = 0; i < images.Count && all < filter.c; i++)
        //        {
        //            var image = images[i];
        //            var result = image.PlatForms.Contains(vkey);
        //            if (!result) continue;
        //            if (image.ChannelType == "vod")
        //            {
        //                //result = ListCache.Instance.Dictionary.ContainsKey(image.Vid);
        //                VideoNode video;
        //                if (ListCache.Instance.Dictionary.TryGetValue(image.Vid, out video))
        //                {
        //                    foreach (var f in filters)
        //                    {
        //                        result = result && f(video, filter);
        //                    }
        //                }
        //                else
        //                    continue;
        //            }
        //            else
        //            {
        //                //result = LiveListCache.Instance.Dictionary.ContainsKey(image.Vid);
        //                LiveVideoNode video;
        //                if (LiveListCache.Instance.Dictionary.TryGetValue(image.Vid, out video))
        //                {
        //                    foreach (var f in filters)
        //                    {
        //                        result = result && f(video, filter);
        //                    }
        //                }
        //                else
        //                    continue;
        //            }
        //            if (result)
        //            {
        //                all++;
        //                XElement playlink;
        //                if (image.ChannelType == "vod")
        //                    playlink = VideoResponseUtils.CreateVodPlayLinkVer2(image.Vid, filter, false);
        //                else
        //                    playlink = VideoResponseUtils.CreateLivePlayLinkVer2(image.Vid, filter, false);
        //                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.Vid),
        //                        new XElement("vtype", image.ChannelType),
        //                        playlink,
        //                        new XElement("cover_imgurl", image.ImageUrl),
        //                        new XElement("onlinetime", image.OnlineTime.ToString("yyyy-MM-dd HH:mm:ss"))
        //                    ));
        //            }
        //        }
        //        return xml.ToString(SaveOptions.DisableFormatting);
        //    }
        //    catch (Exception ex)
        //    {
        //        return BoxUtils.FormatErrorMsg(ex);
        //    }
        //}

        //public string ImageRecommandEx(CoverFilter filter)
        //{
        //    try
        //    {
        //        var images = ConverImageCache.Instance.Items;
        //        int all = 0;
        //        var xml = new XElement("cover_list");
        //        var vkey = new VideoNodeKey(filter.platform, 0, filter.auth);
        //        var filters = VideoNodesUtil.FormateTagFilter(filter);
        //        for (var i = 0; i < images.Count && all < filter.c; i++)
        //        {
        //            var image = images[i];
        //            var result = image.PlatForms.Contains(vkey);
        //            if (!result) continue;
        //            if (image.ChannelType == "vod")
        //            {
        //                VideoNode video;
        //                if (ListCache.Instance.Dictionary.TryGetValue(image.Vid, out video))
        //                {
        //                    foreach (var f in filters)
        //                    {
        //                        result = result && f(video, filter);
        //                    }
        //                }
        //                else
        //                    continue;
        //            }
        //            else
        //            {
        //                LiveVideoNode video;
        //                if (LiveListCache.Instance.Dictionary.TryGetValue(image.Vid, out video))
        //                {
        //                    foreach (var f in filters)
        //                    {
        //                        result = result && f(video, filter);
        //                    }
        //                }
        //                else
        //                    continue;
        //            }
        //            if (result)
        //            {
        //                all++;
        //                XElement playlink;
        //                if (image.ChannelType == "vod")
        //                    playlink = VideoResponseUtils.CreateVodPlayLinkVer2(image.Vid, filter, true);
        //                else
        //                    playlink = VideoResponseUtils.CreateLivePlayLinkVer2(image.Vid, filter, true);
        //                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.Vid),
        //                        new XElement("vtype", image.ChannelType),
        //                        playlink,
        //                        new XElement("cover_imgurl", image.ImageUrl),
        //                        new XElement("onlinetime", image.OnlineTime.ToString("yyyy-MM-dd HH:mm:ss"))
        //                    ));
        //            }
        //        }
        //        return xml.ToString(SaveOptions.DisableFormatting);
        //    }
        //    catch (Exception ex)
        //    {
        //        return BoxUtils.FormatErrorMsg(ex);
        //    }
        //}

        //#endregion

        #region ICover Members


        public string SplashScreeen(CoverFilter filter)
        {
            try
            {
                var modes = filter.mode.FormatStrToInt(SplitArray.LineArray);
                var spls  = SplashScreenCache.Instance.Items;
                if (spls.Count <= 0 || modes.Count <= 0)
                {
                    var xml = new XElement("splashscreen");
                    return(xml.ToString(SaveOptions.DisableFormatting));
                }
                else
                {
                    var xml = new XElement("slist");
                    foreach (var mode in modes)
                    {
                        var xmlquery = from spl in spls
                                       where spl.Mode == mode
                                       select new XElement("splashscreen",
                                                           new XElement("mode", mode),
                                                           new XElement("etag", spl.ETag),
                                                           new XElement("photo", spl.Photo),
                                                           new XElement("expires", spl.Expires.ToString("yyyy-MM-dd HH:mm:ss"))
                                                           );
                        xml.Add(xmlquery);
                    }
                    return(xml.ToString(SaveOptions.DisableFormatting));
                }
            }
            catch (Exception ex)
            {
                return(BoxUtils.FormatErrorMsg(ex));
            }
        }
Exemplo n.º 5
0
        private void deletePicture()
        {
            if (listview_Box_uploads.SelectedItems != null && listview_Box_uploads.SelectedItems.Count > 0)
            {
                for (int i = 0; i < listview_Box_uploads.SelectedItems.Count; i++)
                {
                    BoxInfo      imgurInfo = (BoxInfo)listview_Box_uploads.SelectedItems[i].Tag;
                    DialogResult result    = MessageBox.Show(lang.GetFormattedString(LangKey.delete_question, imgurInfo.Title), lang.GetFormattedString(LangKey.delete_title, imgurInfo.ID), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(BoxPlugin.Attributes.Name, lang.GetString(LangKey.communication_wait));
                        try
                        {
                            BoxUtils.DeleteBoxImage(imgurInfo);
                        }
                        catch (Exception ex)
                        {
                            LOG.Warn("Problem communicating with Box: ", ex);
                        }
                        finally
                        {
                            backgroundForm.CloseDialog();
                        }

                        imgurInfo.Dispose();
                    }
                }
            }
            redraw();
        }
Exemplo n.º 6
0
 public string LiveSearchCh(LiveSearchFilter filter)
 {
     try
     {
         return(CreateSmarkPageList(LuceneNetUtil.LiveSearch(filter, LiveEpgNode.CnNameField, Searcher.SegmentChWord(filter.k), false), filter, false));
     }
     catch (KeyNotFoundException)
     {
         return(NoPlatForm());
     }
     catch (Exception ex)
     {
         return(BoxUtils.FormatErrorMsg(ex));
     }
 }
Exemplo n.º 7
0
 public string LiveParadeSearchEx(LiveSearchFilter filter)
 {
     try
     {
         return(CreateParadeSmarkPageList(LuceneNetUtil.LiveSearchEx(filter, LiveEpgNode.ParadeFields, Searcher.SegmentKeyWord(filter.k), true), filter, true));
     }
     catch (KeyNotFoundException)
     {
         return(NoPlatForm());
     }
     catch (Exception ex)
     {
         return(BoxUtils.FormatErrorMsg(ex));
     }
 }
Exemplo n.º 8
0
 public string TagSearchSmart(TagSearchFilter filter)
 {
     try
     {
         var xml   = new XElement("taglist");
         var count = LuceneNetUtil.TagSearch(filter, EpgIndexNode.NameField, Searcher.SegmentKeyWord(filter.k), xml);
         xml.AddFirst(new XElement("count", count), new XElement("page_count", PageUtils.PageCount(count, filter.c)));
         return(xml.ToString(SaveOptions.DisableFormatting));
     }
     catch (KeyNotFoundException)
     {
         return(NoPlatForm());
     }
     catch (Exception ex)
     {
         return(BoxUtils.FormatErrorMsg(ex));
     }
 }
Exemplo n.º 9
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));
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// 分类扩展接口
 /// </summary>
 public string VideoTypesEx(TagsFilter filter)
 {
     try
     {
         var types   = BoxTypeCache.Instance.Items;
         var filters = VideoNodesUtil.CommonFilter(filter);
         var root    = new XElement("types");
         foreach (var boxtype in types)
         {
             var videos = ListCache.Instance.Items[new VideoNodeKey(filter.platform, boxtype.Key, filter.auth)].OrderArray;
             int count  = 0;
             for (var i = 0; i < videos.Count; i++)
             {
                 bool result = true;
                 var  v      = ListCache.Instance.Dictionary[videos[i]];
                 foreach (var f in filters)
                 {
                     result = result && f(v, filter);
                 }
                 if (result)
                 {
                     count++;
                 }
             }
             root.Add(new XElement("type",
                                   new XElement("tid", boxtype.Value.TypeID),
                                   new XElement("name", boxtype.Value.Language[filter.lang].Title),
                                   new XElement("count", count),
                                   new XElement("image", boxtype.Value.PicLink),
                                   new XElement("tag_dimesion", boxtype.Value.ResponseDimension),
                                   new XElement("treeleft_support", boxtype.Value.TreeSupport)
                                   ));
         }
         return(root.ToString(SaveOptions.DisableFormatting));
     }
     catch (KeyNotFoundException)
     {
         return(NoPlatForm());
     }
     catch (Exception ex)
     {
         return(BoxUtils.FormatErrorMsg(ex));
     }
 }
Exemplo n.º 11
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));
     }
 }