1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-19 17:32:38 +01:00

New: Use Best PageSize for Newznab/Torznab

Max of Default or Max and no more than 100
This commit is contained in:
Bakerboy448 2023-02-11 12:08:34 -06:00 committed by Qstick
parent c6e91e028b
commit c222a1a434
4 changed files with 24 additions and 7 deletions

View File

@ -62,13 +62,21 @@ public void should_parse_recent_feed_from_newznab_nzb_su()
releaseInfo.Size.Should().Be(1183105773);
}
[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);
}
}
}

View File

@ -135,12 +135,21 @@ public void should_parse_recent_feed_from_torznab_animetosho()
}
[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

@ -20,7 +20,7 @@ public class Newznab : HttpIndexerBase<NewznabSettings>
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 @@ public class Torznab : HttpIndexerBase<TorznabSettings>
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()
{