From a77ef187af25da401353c89eb20c99516e20997a Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 11 Jul 2023 06:52:27 +0300 Subject: [PATCH] Fixed: Anime standard format search on Nyaa --- .../Indexers/Nyaa/NyaaRequestGenerator.cs | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/Nyaa/NyaaRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Nyaa/NyaaRequestGenerator.cs index eca0e413d..9340f0a53 100644 --- a/src/NzbDrone.Core/Indexers/Nyaa/NyaaRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Nyaa/NyaaRequestGenerator.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using NzbDrone.Common.Http; using NzbDrone.Core.IndexerSearch.Definitions; @@ -28,7 +29,17 @@ namespace NzbDrone.Core.Indexers.Nyaa public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria) { - return new IndexerPageableRequestChain(); + var pageableRequests = new IndexerPageableRequestChain(); + + if (Settings.AnimeStandardFormatSearch && searchCriteria.SeasonNumber > 0 && searchCriteria.EpisodeNumber > 0) + { + foreach (var searchTitle in searchCriteria.SceneTitles.Select(PrepareQuery)) + { + pageableRequests.Add(GetPagedRequests(MaxPages, $"{searchTitle}+s{searchCriteria.SeasonNumber:00}e{searchCriteria.EpisodeNumber:00}")); + } + } + + return pageableRequests; } public virtual IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria) @@ -37,10 +48,8 @@ namespace NzbDrone.Core.Indexers.Nyaa if (Settings.AnimeStandardFormatSearch && searchCriteria.SeasonNumber > 0) { - foreach (var queryTitle in searchCriteria.SceneTitles) + foreach (var searchTitle in searchCriteria.SceneTitles.Select(PrepareQuery)) { - var searchTitle = PrepareQuery(queryTitle); - pageableRequests.Add(GetPagedRequests(MaxPages, $"{searchTitle}+s{searchCriteria.SeasonNumber:00}")); } } @@ -62,10 +71,8 @@ namespace NzbDrone.Core.Indexers.Nyaa { var pageableRequests = new IndexerPageableRequestChain(); - foreach (var queryTitle in searchCriteria.SceneTitles) + foreach (var searchTitle in searchCriteria.SceneTitles.Select(PrepareQuery)) { - var searchTitle = PrepareQuery(queryTitle); - if (searchCriteria.AbsoluteEpisodeNumber > 0) { pageableRequests.Add(GetPagedRequests(MaxPages, $"{searchTitle}+{searchCriteria.AbsoluteEpisodeNumber:0}")); @@ -99,7 +106,7 @@ namespace NzbDrone.Core.Indexers.Nyaa private IEnumerable GetPagedRequests(int maxPages, string term) { - var baseUrl = string.Format("{0}/?page=rss{1}", Settings.BaseUrl.TrimEnd('/'), Settings.AdditionalParameters); + var baseUrl = $"{Settings.BaseUrl.TrimEnd('/')}/?page=rss{Settings.AdditionalParameters}"; if (term != null) {