New: Use better page size for Newznab/Torznab (up to 100) when supported by the indexer

Closes #5373
This commit is contained in:
bakerboy448 2023-02-12 16:34:04 -06:00 committed by GitHub
parent c1e43e9389
commit ddb25b1095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 6 deletions

View File

@ -94,12 +94,21 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
}
[Test]
public void should_use_pagesize_reported_by_caps()
public void should_use_best_pagesize_reported_by_caps()
{
_caps.MaxPageSize = 30;
_caps.DefaultPageSize = 25;
Subject.PageSize.Should().Be(25);
Subject.PageSize.Should().Be(30);
}
[Test]
public void should_not_use_pagesize_over_100_even_if_reported_in_caps()
{
_caps.MaxPageSize = 250;
_caps.DefaultPageSize = 25;
Subject.PageSize.Should().Be(100);
}
[Test]

View File

@ -136,12 +136,21 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests
}
[Test]
public void should_use_pagesize_reported_by_caps()
public void should_use_best_pagesize_reported_by_caps()
{
_caps.MaxPageSize = 30;
_caps.DefaultPageSize = 25;
Subject.PageSize.Should().Be(25);
Subject.PageSize.Should().Be(30);
}
[Test]
public void should_not_use_pagesize_over_100_even_if_reported_in_caps()
{
_caps.MaxPageSize = 250;
_caps.DefaultPageSize = 25;
Subject.PageSize.Should().Be(100);
}
[TestCase("http://localhost:9117/", "/api")]

View File

@ -21,7 +21,7 @@ namespace NzbDrone.Core.Indexers.Newznab
public override DownloadProtocol Protocol => DownloadProtocol.Usenet;
public override int PageSize => _capabilitiesProvider.GetCapabilities(Settings).DefaultPageSize;
public override int PageSize => Math.Min(100, Math.Max(_capabilitiesProvider.GetCapabilities(Settings).DefaultPageSize, _capabilitiesProvider.GetCapabilities(Settings).MaxPageSize));
public override IIndexerRequestGenerator GetRequestGenerator()
{

View File

@ -20,7 +20,7 @@ namespace NzbDrone.Core.Indexers.Torznab
public override string Name => "Torznab";
public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
public override int PageSize => _capabilitiesProvider.GetCapabilities(Settings).DefaultPageSize;
public override int PageSize => Math.Min(100, Math.Max(_capabilitiesProvider.GetCapabilities(Settings).DefaultPageSize, _capabilitiesProvider.GetCapabilities(Settings).MaxPageSize));
public override IIndexerRequestGenerator GetRequestGenerator()
{