Fixed: Newznab/Torznab used wrong query if tvrageid was unknown in combination with a specific indexer capability profile.

This commit is contained in:
Taloth Saldono 2016-03-28 20:15:31 +02:00
parent 947f494e72
commit 4c5707bba8
2 changed files with 26 additions and 7 deletions

View File

@ -234,6 +234,21 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
page.Url.Query.Should().Contain("q=");
}
[Test]
public void should_not_use_aggregrated_id_search_if_no_ids_are_known()
{
_capabilities.SupportedTvSearchParameters = new[] { "q", "rid", "season", "ep" };
_capabilities.SupportsAggregateIdSearch = true; // Turns true if indexer supplies supportedParams.
_singleEpisodeSearchCriteria.Series.TvRageId = 0;
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
var page = results.GetTier(0).First().First();
page.Url.Query.Should().Contain("q=");
}
[Test]
public void should_fallback_to_q()
{

View File

@ -183,21 +183,25 @@ namespace NzbDrone.Core.Indexers.Newznab
private void AddTvIdPageableRequests(IndexerPageableRequestChain chain, int maxPages, IEnumerable<int> categories, SearchCriteriaBase searchCriteria, string parameters)
{
if (SupportsAggregatedIdSearch && (SupportsTvdbSearch || SupportsTvRageSearch || SupportsTvMazeSearch))
var includeTvdbSearch = SupportsTvdbSearch && searchCriteria.Series.TvdbId > 0;
var includeTvRageSearch = SupportsTvRageSearch && searchCriteria.Series.TvRageId > 0;
var includeTvMazeSearch = SupportsTvMazeSearch && searchCriteria.Series.TvMazeId > 0;
if (SupportsAggregatedIdSearch && (includeTvdbSearch || includeTvRageSearch || includeTvMazeSearch))
{
var ids = "";
if (searchCriteria.Series.TvdbId > 0 && SupportsTvdbSearch)
if (includeTvdbSearch)
{
ids += "&tvdbid=" + searchCriteria.Series.TvdbId;
}
if (searchCriteria.Series.TvRageId > 0 && SupportsTvRageSearch)
if (includeTvRageSearch)
{
ids += "&rid=" + searchCriteria.Series.TvRageId;
}
if (searchCriteria.Series.TvMazeId > 0 && SupportsTvMazeSearch)
if (includeTvMazeSearch)
{
ids += "&tvmazeid=" + searchCriteria.Series.TvMazeId;
}
@ -206,18 +210,18 @@ namespace NzbDrone.Core.Indexers.Newznab
}
else
{
if (searchCriteria.Series.TvdbId > 0 && SupportsTvdbSearch)
if (includeTvdbSearch)
{
chain.Add(GetPagedRequests(maxPages, categories, "tvsearch",
string.Format("&tvdbid={0}{1}", searchCriteria.Series.TvdbId, parameters)));
}
else if (searchCriteria.Series.TvRageId > 0 && SupportsTvRageSearch)
else if (includeTvRageSearch)
{
chain.Add(GetPagedRequests(maxPages, categories, "tvsearch",
string.Format("&rid={0}{1}", searchCriteria.Series.TvRageId, parameters)));
}
else if (searchCriteria.Series.TvMazeId > 0 && SupportsTvMazeSearch)
else if (includeTvMazeSearch)
{
chain.Add(GetPagedRequests(maxPages, categories, "tvsearch",
string.Format("&tvmazeid={0}{1}", searchCriteria.Series.TvMazeId, parameters)));