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

pull/2/head
Taloth Saldono 9 years ago
parent 1ad1d73c91
commit 9162e97dd5

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

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

@ -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() public virtual IndexerPageableRequestChain GetRecentRequests()
{ {
var pageableRequests = new IndexerPageableRequestChain(); 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) 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) if (searchCriteria.Series.TvdbId > 0 && SupportsTvdbSearch)
{ {

Loading…
Cancel
Save