mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Adding an aggregate torznab feed for all configured trackers (#1312)
* Adding an aggregate torznab feed for all configured trackers This adds just a basic first implementation of a special torznab feed that will make all configured trackers available with all the supported query params. - This should close #1247 - This also contributes to #921 * Adding missing file * Add missing implementation from Test project
This commit is contained in:
51
src/Jackett/Indexers/AggregateIndexer.cs
Normal file
51
src/Jackett/Indexers/AggregateIndexer.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Jackett.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Jackett.Services;
|
||||
using Jackett.Utils.Clients;
|
||||
using NLog;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
class AggregateIndexer : BaseIndexer, IIndexer
|
||||
{
|
||||
private IEnumerable<IIndexer> Indexers;
|
||||
public AggregateIndexer(IIndexerManagerService i, IWebClient wc, Logger l, IProtectionService ps)
|
||||
: base("AggregateSearch", "http://127.0.0.1/", "This feed includes all configured trackers", i, wc, l, new Models.IndexerConfig.ConfigurationData(), ps)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetIndexers(IEnumerable<IIndexer> indexers)
|
||||
{
|
||||
Indexers = indexers;
|
||||
base.IsConfigured = true;
|
||||
}
|
||||
|
||||
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
return IndexerConfigurationStatus.Completed;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||
{
|
||||
var tasks = new List<Task<IEnumerable<ReleaseInfo>>>();
|
||||
foreach (var indexer in Indexers.Where(i => i.IsConfigured))
|
||||
tasks.Add(indexer.PerformQuery(query));
|
||||
|
||||
var t = Task.WhenAll<IEnumerable<ReleaseInfo>>(tasks);
|
||||
t.Wait();
|
||||
|
||||
IEnumerable<ReleaseInfo> result = t.Result.SelectMany(x => x).OrderByDescending(r => r.PublishDate);
|
||||
// Limiting the response size might be interesting for use-cases where there are
|
||||
// tons of trackers configured in Jackett. For now just use the limit param if
|
||||
// someone wants to do that.
|
||||
if (query.Limit > 0)
|
||||
result = result.Take(query.Limit);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user