当前位置: 首页>>代码示例>>C#>>正文


C# TorznabQuery.ExpandCatsToSubCats方法代码示例

本文整理汇总了C#中Jackett.Models.TorznabQuery.ExpandCatsToSubCats方法的典型用法代码示例。如果您正苦于以下问题:C# TorznabQuery.ExpandCatsToSubCats方法的具体用法?C# TorznabQuery.ExpandCatsToSubCats怎么用?C# TorznabQuery.ExpandCatsToSubCats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Jackett.Models.TorznabQuery的用法示例。


在下文中一共展示了TorznabQuery.ExpandCatsToSubCats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Search

        public ManualSearchResult Search([FromBody]AdminSearch value)
        {
            var results = new List<TrackerCacheResult>();
            var query = new TorznabQuery()
            {
                SearchTerm = value.Query,
                Categories = value.Category == 0 ? new int[0] : new int[1] { value.Category }
            };

            query.ExpandCatsToSubCats();

            var trackers = indexerService.GetAllIndexers().Where(t => t.IsConfigured).ToList();
            if (!string.IsNullOrWhiteSpace(value.Tracker))
            {
                trackers = trackers.Where(t => t.ID == value.Tracker).ToList();
            }

            if (value.Category != 0)
            {
                trackers = trackers.Where(t => t.TorznabCaps.Categories.Select(c => c.ID).Contains(value.Category)).ToList();
            }

            Parallel.ForEach(trackers.ToList(), indexer =>
            {
                try
                {
                    var searchResults = indexer.PerformQuery(query).Result;
                    searchResults = indexer.CleanLinks(searchResults);
                    cacheService.CacheRssResults(indexer, searchResults);
                    searchResults = indexer.FilterResults(query, searchResults);

                    lock (results)
                    {
                        foreach (var result in searchResults)
                        {
                            var item = Mapper.Map<TrackerCacheResult>(result);
                            item.Tracker = indexer.DisplayName;
                            item.TrackerId = indexer.ID;
                            item.Peers = item.Peers - item.Seeders; // Use peers as leechers
                            results.Add(item);
                        }
                    }
                }
                catch (Exception e)
                {
                    logger.Error(e, "An error occured during manual search on " + indexer.DisplayName + ":  " + e.Message);
                }
            });

            ConfigureCacheResults(results);

            if (trackers.Count > 1)
            {
                results = results.OrderByDescending(d => d.PublishDate).ToList();
            }

            var manualResult = new ManualSearchResult()
            {
                Results = results,
                Indexers = trackers.Select(t => t.DisplayName).ToList()
            };


            if (manualResult.Indexers.Count == 0)
                manualResult.Indexers = new List<string>() { "None" };

            logger.Info(string.Format("Manual search for \"{0}\" on {1} with {2} results.", query.GetQueryString(), string.Join(", ", manualResult.Indexers), manualResult.Results.Count));
            return manualResult;
        }
开发者ID:Drayden,项目名称:Jackett,代码行数:69,代码来源:AdminController.cs


注:本文中的Jackett.Models.TorznabQuery.ExpandCatsToSubCats方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。