1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 04:22:30 +01:00

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 @@ public class NewznabCapabilities
{
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 @@ private NewznabCapabilities ParseCapabilities(HttpResponse response)
else if (xmlTvSearch.Attribute("supportedParams") != null)
{
capabilities.SupportedTvSearchParameters = xmlTvSearch.Attribute("supportedParams").Value.Split(',');
capabilities.SupportsAggregateIdSearch = true;
}
}

View File

@ -72,6 +72,16 @@ private bool SupportsTvRageSearch
}
}
private bool SupportsAggregatedIdSearch
{
get
{
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
return capabilities.SupportsAggregateIdSearch;
}
}
public virtual IndexerPageableRequestChain GetRecentRequests()
{
var pageableRequests = new IndexerPageableRequestChain();
@ -160,6 +170,23 @@ public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearc
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)
{