New: Use IMDB ID when searching supported indexers
This commit is contained in:
parent
c90672a5ab
commit
24fba7a36d
|
@ -28,7 +28,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
|
|||
|
||||
_singleEpisodeSearchCriteria = new SingleEpisodeSearchCriteria
|
||||
{
|
||||
Series = new Tv.Series { TvRageId = 10, TvdbId = 20, TvMazeId = 30 },
|
||||
Series = new Tv.Series { TvRageId = 10, TvdbId = 20, TvMazeId = 30, ImdbId ="t40" },
|
||||
SceneTitles = new List<string> { "Monkey Island" },
|
||||
SeasonNumber = 1,
|
||||
EpisodeNumber = 2
|
||||
|
@ -189,6 +189,19 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
|
|||
page.Url.Query.Should().Contain("tvmazeid=30");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_search_by_imdbid_if_supported()
|
||||
{
|
||||
_capabilities.SupportedTvSearchParameters = new[] { "q", "imdbid", "season", "ep" };
|
||||
|
||||
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
|
||||
results.GetTier(0).Should().HaveCount(1);
|
||||
|
||||
var page = results.GetAllTiers().First().First();
|
||||
|
||||
page.Url.Query.Should().Contain("imdbid=t40");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_prefer_search_by_tvdbid_if_rid_supported()
|
||||
{
|
||||
|
|
|
@ -57,6 +57,18 @@ namespace NzbDrone.Core.Indexers.Newznab
|
|||
capabilities.SupportedTvSearchParameters.Contains("ep");
|
||||
}
|
||||
}
|
||||
private bool SupportsImdbSearch
|
||||
{
|
||||
get
|
||||
{
|
||||
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||
|
||||
return capabilities.SupportedTvSearchParameters != null &&
|
||||
capabilities.SupportedTvSearchParameters.Contains("imdbid") &&
|
||||
capabilities.SupportedTvSearchParameters.Contains("season") &&
|
||||
capabilities.SupportedTvSearchParameters.Contains("ep");
|
||||
}
|
||||
}
|
||||
|
||||
private bool SupportsTvRageSearch
|
||||
{
|
||||
|
@ -198,6 +210,7 @@ namespace NzbDrone.Core.Indexers.Newznab
|
|||
private void AddTvIdPageableRequests(IndexerPageableRequestChain chain, int maxPages, IEnumerable<int> categories, SearchCriteriaBase searchCriteria, string parameters)
|
||||
{
|
||||
var includeTvdbSearch = SupportsTvdbSearch && searchCriteria.Series.TvdbId > 0;
|
||||
var includeImdbSearch = SupportsImdbSearch && searchCriteria.Series.ImdbId.IsNotNullOrWhiteSpace();
|
||||
var includeTvRageSearch = SupportsTvRageSearch && searchCriteria.Series.TvRageId > 0;
|
||||
var includeTvMazeSearch = SupportsTvMazeSearch && searchCriteria.Series.TvMazeId > 0;
|
||||
|
||||
|
@ -209,6 +222,10 @@ namespace NzbDrone.Core.Indexers.Newznab
|
|||
{
|
||||
ids += "&tvdbid=" + searchCriteria.Series.TvdbId;
|
||||
}
|
||||
if (includeImdbSearch)
|
||||
{
|
||||
ids += "&imdbid=" + searchCriteria.Series.ImdbId;
|
||||
}
|
||||
|
||||
if (includeTvRageSearch)
|
||||
{
|
||||
|
@ -229,6 +246,11 @@ namespace NzbDrone.Core.Indexers.Newznab
|
|||
chain.Add(GetPagedRequests(maxPages, categories, "tvsearch",
|
||||
string.Format("&tvdbid={0}{1}", searchCriteria.Series.TvdbId, parameters)));
|
||||
}
|
||||
else if (includeImdbSearch)
|
||||
{
|
||||
chain.Add(GetPagedRequests(maxPages, categories, "tvsearch",
|
||||
string.Format("&imdbid={0}{1}", searchCriteria.Series.ImdbId, parameters)));
|
||||
}
|
||||
else if (includeTvRageSearch)
|
||||
{
|
||||
chain.Add(GetPagedRequests(maxPages, categories, "tvsearch",
|
||||
|
|
Loading…
Reference in New Issue