Remove unsupported pagination for Nyaa

(cherry picked from commit fef525ddb8b5f91bb36b3c9e652663fccb098a00)

Closes #4428
This commit is contained in:
ilike2burnthing 2024-01-12 00:37:31 +00:00 committed by Bogdan
parent 729f2b7089
commit 1e5e756585
2 changed files with 7 additions and 29 deletions

View File

@ -10,7 +10,6 @@ namespace NzbDrone.Core.Indexers.Nyaa
public override string Name => "Nyaa"; public override string Name => "Nyaa";
public override DownloadProtocol Protocol => DownloadProtocol.Torrent; public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
public override int PageSize => 75;
public Nyaa(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger) public Nyaa(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger)
: base(httpClient, indexerStatusService, configService, parsingService, logger) : base(httpClient, indexerStatusService, configService, parsingService, logger)
@ -19,7 +18,7 @@ namespace NzbDrone.Core.Indexers.Nyaa
public override IIndexerRequestGenerator GetRequestGenerator() public override IIndexerRequestGenerator GetRequestGenerator()
{ {
return new NyaaRequestGenerator() { Settings = Settings, PageSize = PageSize }; return new NyaaRequestGenerator() { Settings = Settings };
} }
public override IParseIndexerResponse GetParser() public override IParseIndexerResponse GetParser()

View File

@ -9,20 +9,11 @@ namespace NzbDrone.Core.Indexers.Nyaa
{ {
public NyaaSettings Settings { get; set; } public NyaaSettings Settings { get; set; }
public int MaxPages { get; set; }
public int PageSize { get; set; }
public NyaaRequestGenerator()
{
MaxPages = 3;
PageSize = 75;
}
public virtual IndexerPageableRequestChain GetRecentRequests() public virtual IndexerPageableRequestChain GetRecentRequests()
{ {
var pageableRequests = new IndexerPageableRequestChain(); var pageableRequests = new IndexerPageableRequestChain();
pageableRequests.Add(GetPagedRequests(MaxPages, null)); pageableRequests.Add(GetPagedRequests(null));
return pageableRequests; return pageableRequests;
} }
@ -34,7 +25,7 @@ namespace NzbDrone.Core.Indexers.Nyaa
var artistQuery = searchCriteria.CleanArtistQuery.Replace("+", " ").Trim(); var artistQuery = searchCriteria.CleanArtistQuery.Replace("+", " ").Trim();
var albumQuery = searchCriteria.CleanAlbumQuery.Replace("+", " ").Trim(); var albumQuery = searchCriteria.CleanAlbumQuery.Replace("+", " ").Trim();
pageableRequests.Add(GetPagedRequests(MaxPages, PrepareQuery($"{artistQuery} {albumQuery}"))); pageableRequests.Add(GetPagedRequests(PrepareQuery($"{artistQuery} {albumQuery}")));
return pageableRequests; return pageableRequests;
} }
@ -45,33 +36,21 @@ namespace NzbDrone.Core.Indexers.Nyaa
var artistQuery = searchCriteria.CleanArtistQuery.Replace("+", " ").Trim(); var artistQuery = searchCriteria.CleanArtistQuery.Replace("+", " ").Trim();
pageableRequests.Add(GetPagedRequests(MaxPages, PrepareQuery(artistQuery))); pageableRequests.Add(GetPagedRequests(PrepareQuery(artistQuery)));
return pageableRequests; return pageableRequests;
} }
private IEnumerable<IndexerRequest> GetPagedRequests(int maxPages, string term) private IEnumerable<IndexerRequest> GetPagedRequests(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) if (term != null)
{ {
baseUrl += "&term=" + term; baseUrl += "&term=" + term;
} }
if (PageSize == 0) yield return new IndexerRequest(baseUrl, HttpAccept.Rss);
{
yield return new IndexerRequest(baseUrl, HttpAccept.Rss);
}
else
{
yield return new IndexerRequest(baseUrl, HttpAccept.Rss);
for (var page = 1; page < maxPages; page++)
{
yield return new IndexerRequest($"{baseUrl}&offset={page + 1}", HttpAccept.Rss);
}
}
} }
private string PrepareQuery(string query) private string PrepareQuery(string query)