Skip to content

Commit

Permalink
New: Use better page size for Newznab/Torznab (up to 100) when suppor…
Browse files Browse the repository at this point in the history
…ted by the indexer

(cherry picked from commit ddb25b109575cc378462a1c3a64705f2003f01f0)

Closes #2181
  • Loading branch information
bakerboy448 authored and mynameisbogdan committed Jul 29, 2023
1 parent b04b483 commit ad7b110
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
13 changes: 11 additions & 2 deletions src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabFixture.cs
Expand Up @@ -65,12 +65,21 @@ public void should_parse_recent_feed_from_newznab_nzb_su()
}

[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]
Expand Down
13 changes: 11 additions & 2 deletions src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs
Expand Up @@ -103,12 +103,21 @@ public void should_parse_recent_feed_from_torznab_tpb()
}

[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")]
Expand Down
2 changes: 1 addition & 1 deletion src/NzbDrone.Core/Indexers/Newznab/Newznab.cs
Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion src/NzbDrone.Core/Indexers/Torznab/Torznab.cs
Expand Up @@ -19,7 +19,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()
{
Expand Down

0 comments on commit ad7b110

Please sign in to comment.