Added support for querying newznab with multiple ids in one query.

This commit is contained in:
Taloth Saldono 2015-10-09 20:57:38 +02:00
parent 1ad1d73c91
commit 9162e97dd5
3 changed files with 30 additions and 0 deletions

View File

@ -7,12 +7,14 @@ namespace NzbDrone.Core.Indexers.Newznab
{
public string[] SupportedSearchParameters { get; set; }
public string[] SupportedTvSearchParameters { get; set; }
public bool SupportsAggregateIdSearch { get; set; }
public List<NewznabCategory> Categories { get; set; }
public NewznabCapabilities()
{
SupportedSearchParameters = new[] { "q" };
SupportedTvSearchParameters = new[] { "q", "rid", "season", "ep" }; // This should remain 'rid' for older newznab installs.
SupportsAggregateIdSearch = false;
Categories = new List<NewznabCategory>();
}
}

View File

@ -89,6 +89,7 @@ namespace NzbDrone.Core.Indexers.Newznab
else if (xmlTvSearch.Attribute("supportedParams") != null)
{
capabilities.SupportedTvSearchParameters = xmlTvSearch.Attribute("supportedParams").Value.Split(',');
capabilities.SupportsAggregateIdSearch = true;
}
}

View File

@ -72,6 +72,16 @@ namespace NzbDrone.Core.Indexers.Newznab
}
}
private bool SupportsAggregatedIdSearch
{
get
{
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
return capabilities.SupportsAggregateIdSearch;
}
}
public virtual IndexerPageableRequestChain GetRecentRequests()
{
var pageableRequests = new IndexerPageableRequestChain();
@ -160,6 +170,23 @@ namespace NzbDrone.Core.Indexers.Newznab
private void AddTvIdPageableRequests(IndexerPageableRequestChain chain, int maxPages, IEnumerable<int> categories, SearchCriteriaBase searchCriteria, string parameters)
{
if (SupportsAggregatedIdSearch)
{
var ids = "";
if (searchCriteria.Series.TvdbId > 0 && SupportsTvdbSearch)
{
ids += "&tvdbid=" + searchCriteria.Series.TvdbId;
}
if (searchCriteria.Series.TvRageId > 0 && SupportsTvRageSearch)
{
ids += "&rid=" + searchCriteria.Series.TvRageId;
}
chain.Add(GetPagedRequests(maxPages, categories, "tvsearch", ids + parameters));
}
else
{
if (searchCriteria.Series.TvdbId > 0 && SupportsTvdbSearch)
{