From d581de00c9424436557f96228224d918dc6de5a3 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 3 Aug 2023 17:22:47 -0700 Subject: [PATCH] Fixed: Duplicate searches when Anime Standard Format Search enabled on indexer and series has multiple aliases --- .../NewznabRequestGeneratorFixture.cs | 4 +-- .../Newznab/NewznabRequestGenerator.cs | 26 ++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs index 6e82f2c66..72ee0b3ad 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabRequestGeneratorFixture.cs @@ -157,8 +157,8 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests var pages = results.GetTier(0).Select(t => t.First()).ToList(); pages[0].Url.FullUri.Should().Contain("rid=10&q=100"); - pages[1].Url.FullUri.Should().Contain("q=Monkey%20Island+100"); - pages[2].Url.FullUri.Should().Contain("rid=10&season=5&ep=4"); + pages[1].Url.FullUri.Should().Contain("rid=10&season=5&ep=4"); + pages[2].Url.FullUri.Should().Contain("q=Monkey%20Island+100"); pages[3].Url.FullUri.Should().Contain("q=Monkey%20Island&season=5&ep=4"); } diff --git a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs index bc5e5b96d..217d1c86b 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/NewznabRequestGenerator.cs @@ -391,26 +391,34 @@ namespace NzbDrone.Core.Indexers.Newznab if (SupportsSearch) { - var queryTitles = TextSearchEngine == "raw" ? searchCriteria.SceneTitles : searchCriteria.CleanSceneTitles; - foreach (var queryTitle in queryTitles) + AddTvIdPageableRequests(pageableRequests, + Settings.AnimeCategories, + searchCriteria, + $"&q={searchCriteria.AbsoluteEpisodeNumber:00}"); + + var includeAnimeStandardFormatSearch = Settings.AnimeStandardFormatSearch && + searchCriteria.SeasonNumber > 0 && + searchCriteria.EpisodeNumber > 0; + + if (includeAnimeStandardFormatSearch) { AddTvIdPageableRequests(pageableRequests, Settings.AnimeCategories, searchCriteria, - $"&q={searchCriteria.AbsoluteEpisodeNumber:00}"); + $"&season={NewznabifySeasonNumber(searchCriteria.SeasonNumber)}&ep={searchCriteria.EpisodeNumber}"); + } + var queryTitles = TextSearchEngine == "raw" ? searchCriteria.SceneTitles : searchCriteria.CleanSceneTitles; + + foreach (var queryTitle in queryTitles) + { pageableRequests.Add(GetPagedRequests(MaxPages, Settings.AnimeCategories, "search", $"&q={NewsnabifyTitle(queryTitle)}+{searchCriteria.AbsoluteEpisodeNumber:00}")); - if (Settings.AnimeStandardFormatSearch && searchCriteria.SeasonNumber > 0 && searchCriteria.EpisodeNumber > 0) + if (includeAnimeStandardFormatSearch) { - AddTvIdPageableRequests(pageableRequests, - Settings.AnimeCategories, - searchCriteria, - $"&season={NewznabifySeasonNumber(searchCriteria.SeasonNumber)}&ep={searchCriteria.EpisodeNumber}"); - pageableRequests.Add(GetPagedRequests(MaxPages, Settings.AnimeCategories, "tvsearch",