diff --git a/src/NzbDrone.Core/Indexers/Nyaa/Nyaa.cs b/src/NzbDrone.Core/Indexers/Nyaa/Nyaa.cs index d2d63cbf0..89ecaadb3 100644 --- a/src/NzbDrone.Core/Indexers/Nyaa/Nyaa.cs +++ b/src/NzbDrone.Core/Indexers/Nyaa/Nyaa.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Indexers.Nyaa public override string Name => "Nyaa"; public override DownloadProtocol Protocol => DownloadProtocol.Torrent; - public override int PageSize => 100; + public override int PageSize => 75; public Nyaa(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger) : base(httpClient, indexerStatusService, configService, parsingService, logger) diff --git a/src/NzbDrone.Core/Indexers/Nyaa/NyaaRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Nyaa/NyaaRequestGenerator.cs index 8157e5fc0..0b2d15ceb 100644 --- a/src/NzbDrone.Core/Indexers/Nyaa/NyaaRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Nyaa/NyaaRequestGenerator.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using NzbDrone.Common.Http; using NzbDrone.Core.IndexerSearch.Definitions; @@ -13,8 +14,8 @@ namespace NzbDrone.Core.Indexers.Nyaa public NyaaRequestGenerator() { - MaxPages = 30; - PageSize = 100; + MaxPages = 3; + PageSize = 75; } public virtual IndexerPageableRequestChain GetRecentRequests() @@ -28,12 +29,25 @@ namespace NzbDrone.Core.Indexers.Nyaa public virtual IndexerPageableRequestChain GetSearchRequests(AlbumSearchCriteria searchCriteria) { - throw new System.NotImplementedException(); + var pageableRequests = new IndexerPageableRequestChain(); + + var artistQuery = searchCriteria.CleanArtistQuery.Replace("+", " ").Trim(); + var albumQuery = searchCriteria.CleanAlbumQuery.Replace("+", " ").Trim(); + + pageableRequests.Add(GetPagedRequests(MaxPages, PrepareQuery($"{artistQuery} {albumQuery}"))); + + return pageableRequests; } public virtual IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria searchCriteria) { - throw new System.NotImplementedException(); + var pageableRequests = new IndexerPageableRequestChain(); + + var artistQuery = searchCriteria.CleanArtistQuery.Replace("+", " ").Trim(); + + pageableRequests.Add(GetPagedRequests(MaxPages, PrepareQuery(artistQuery))); + + return pageableRequests; } private IEnumerable GetPagedRequests(int maxPages, string term) @@ -62,7 +76,7 @@ namespace NzbDrone.Core.Indexers.Nyaa private string PrepareQuery(string query) { - return query.Replace(' ', '+'); + return Uri.EscapeDataString(query); } } }