Remove unsupported pagination for Nyaa

(cherry picked from commit fef525ddb8b5f91bb36b3c9e652663fccb098a00)

Closes #3180
pull/3185/head
ilike2burnthing 9 months ago committed by Bogdan
parent 4aec7a0ea7
commit f9ba00c9e7

@ -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 => 100;
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()

@ -8,20 +8,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 = 30;
PageSize = 100;
}
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;
} }
@ -36,28 +27,16 @@ namespace NzbDrone.Core.Indexers.Nyaa
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
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)

Loading…
Cancel
Save