mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-31 07:52:37 +01:00
Added support for title query parameter to newznab/torznab, receiving raw series title
This commit is contained in:
parent
200aee52f7
commit
05dd17aacb
@ -261,6 +261,42 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
|
||||
page.Url.Query.Should().Contain("q=");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_fallback_to_title()
|
||||
{
|
||||
_capabilities.SupportedTvSearchParameters = new[] { "q", "title", "tvdbid", "rid", "season", "ep" };
|
||||
_capabilities.SupportsAggregateIdSearch = true;
|
||||
|
||||
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
|
||||
results.Tiers.Should().Be(2);
|
||||
|
||||
var pageTier2 = results.GetTier(1).First().First();
|
||||
|
||||
pageTier2.Url.Query.Should().NotContain("tvdbid=20");
|
||||
pageTier2.Url.Query.Should().NotContain("rid=10");
|
||||
pageTier2.Url.Query.Should().NotContain("q=");
|
||||
pageTier2.Url.Query.Should().Contain("title=Monkey%20Island");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_url_encode_title()
|
||||
{
|
||||
_capabilities.SupportedTvSearchParameters = new[] { "q", "title", "tvdbid", "rid", "season", "ep" };
|
||||
_capabilities.SupportsAggregateIdSearch = true;
|
||||
|
||||
_singleEpisodeSearchCriteria.SceneTitles[0] = "Elith & Little";
|
||||
|
||||
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
|
||||
results.Tiers.Should().Be(2);
|
||||
|
||||
var pageTier2 = results.GetTier(1).First().First();
|
||||
|
||||
pageTier2.Url.Query.Should().NotContain("tvdbid=20");
|
||||
pageTier2.Url.Query.Should().NotContain("rid=10");
|
||||
pageTier2.Url.Query.Should().NotContain("q=");
|
||||
pageTier2.Url.Query.Should().Contain("title=Elith%20%26%20Little");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_fallback_to_q()
|
||||
{
|
||||
|
@ -47,6 +47,19 @@ namespace NzbDrone.Core.Indexers.Newznab
|
||||
}
|
||||
}
|
||||
|
||||
private bool SupportsTvTitleSearch
|
||||
{
|
||||
get
|
||||
{
|
||||
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||
|
||||
return capabilities.SupportedTvSearchParameters != null &&
|
||||
capabilities.SupportedTvSearchParameters.Contains("title") &&
|
||||
capabilities.SupportedTvSearchParameters.Contains("season") &&
|
||||
capabilities.SupportedTvSearchParameters.Contains("ep");
|
||||
}
|
||||
}
|
||||
|
||||
private bool SupportsTvdbSearch
|
||||
{
|
||||
get
|
||||
@ -275,7 +288,19 @@ namespace NzbDrone.Core.Indexers.Newznab
|
||||
}
|
||||
}
|
||||
|
||||
if (SupportsTvSearch)
|
||||
|
||||
if (SupportsTvTitleSearch)
|
||||
{
|
||||
chain.AddTier();
|
||||
foreach (var searchTerm in searchCriteria.SceneTitles)
|
||||
{
|
||||
chain.Add(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
string.Format("&title={0}{1}",
|
||||
Uri.EscapeDataString(searchTerm),
|
||||
parameters)));
|
||||
}
|
||||
}
|
||||
else if (SupportsTvSearch)
|
||||
{
|
||||
chain.AddTier();
|
||||
foreach (var queryTitle in searchCriteria.QueryTitles)
|
||||
@ -290,16 +315,29 @@ namespace NzbDrone.Core.Indexers.Newznab
|
||||
|
||||
private void AddSceneTitlePageableRequests(IndexerPageableRequestChain chain, IEnumerable<int> categories, SearchCriteriaBase searchCriteria, Func<SceneMapping, string> parametersFunc)
|
||||
{
|
||||
foreach (var sceneMappingGroup in searchCriteria.SceneMappings.GroupBy(v => v.SceneSeasonNumber))
|
||||
if (searchCriteria.SceneMappings != null)
|
||||
{
|
||||
var parameters = parametersFunc(sceneMappingGroup.First());
|
||||
|
||||
foreach (var searchTerm in sceneMappingGroup.Select(v => v.SearchTerm).Distinct())
|
||||
foreach (var sceneMappingGroup in searchCriteria.SceneMappings.GroupBy(v => v.SceneSeasonNumber))
|
||||
{
|
||||
chain.AddToTier(0, GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
string.Format("&q={0}{1}",
|
||||
NewsnabifyTitle(searchTerm),
|
||||
parameters)));
|
||||
var parameters = parametersFunc(sceneMappingGroup.First());
|
||||
|
||||
foreach (var searchTerm in sceneMappingGroup.Select(v => v.SearchTerm).Distinct())
|
||||
{
|
||||
if (SupportsTvTitleSearch)
|
||||
{
|
||||
chain.AddToTier(0, GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
string.Format("&title={0}{1}",
|
||||
Uri.EscapeDataString(searchTerm),
|
||||
parameters)));
|
||||
}
|
||||
else if (SupportsTvSearch)
|
||||
{
|
||||
chain.AddToTier(0, GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
string.Format("&q={0}{1}",
|
||||
NewsnabifyTitle(searchTerm),
|
||||
parameters)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user