From 8917347c0b7085ddfe6b88604807a96b6fe0540e Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 10 Jan 2023 15:22:42 +0200 Subject: [PATCH] Fixed: (IPTorrents) Fix pagination when limit is zero --- .../Indexers/Definitions/IPTorrents.cs | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/Definitions/IPTorrents.cs b/src/NzbDrone.Core/Indexers/Definitions/IPTorrents.cs index 135420f04..636452672 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/IPTorrents.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/IPTorrents.cs @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Indexers.Definitions { public override string Name => "IPTorrents"; - public override string[] IndexerUrls => new string[] + public override string[] IndexerUrls => new[] { "https://iptorrents.com/", "https://iptorrents.me/", @@ -46,7 +46,7 @@ namespace NzbDrone.Core.Indexers.Definitions public override IIndexerRequestGenerator GetRequestGenerator() { - return new IPTorrentsRequestGenerator() { Settings = Settings, Capabilities = Capabilities }; + return new IPTorrentsRequestGenerator { Settings = Settings, Capabilities = Capabilities }; } public override IParseIndexerResponse GetParser() @@ -64,21 +64,21 @@ namespace NzbDrone.Core.Indexers.Definitions var caps = new IndexerCapabilities { TvSearchParams = new List - { - TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep, TvSearchParam.ImdbId - }, + { + TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep, TvSearchParam.ImdbId + }, MovieSearchParams = new List - { - MovieSearchParam.Q, MovieSearchParam.ImdbId - }, + { + MovieSearchParam.Q, MovieSearchParam.ImdbId + }, MusicSearchParams = new List - { - MusicSearchParam.Q - }, + { + MusicSearchParam.Q + }, BookSearchParams = new List - { - BookSearchParam.Q - } + { + BookSearchParam.Q + } }; caps.Categories.AddCategoryMapping(72, NewznabStandardCategory.Movies, "Movies"); @@ -161,10 +161,6 @@ namespace NzbDrone.Core.Indexers.Definitions public IPTorrentsSettings Settings { get; set; } public IndexerCapabilities Capabilities { get; set; } - public IPTorrentsRequestGenerator() - { - } - private IEnumerable GetPagedRequests(string term, int[] categories, int limit, int offset, string imdbId = null) { var searchUrl = Settings.BaseUrl + "t"; @@ -194,9 +190,16 @@ namespace NzbDrone.Core.Indexers.Definitions qc.Add(cat, string.Empty); } - qc.Add("p", ((offset / limit) + 1).ToString()); + if (offset > 0 && limit > 0) + { + var page = (int)(offset / limit) + 1; + qc.Add("p", page.ToString()); + } - searchUrl = searchUrl + "?" + qc.GetQueryString(); + if (qc.Count > 0) + { + searchUrl += $"?{qc.GetQueryString()}"; + } var request = new IndexerRequest(searchUrl, HttpAccept.Html); @@ -356,10 +359,6 @@ namespace NzbDrone.Core.Indexers.Definitions public class IPTorrentsSettings : CookieTorrentBaseSettings { - public IPTorrentsSettings() - { - } - [FieldDefinition(2, Label = "Cookie User-Agent", Type = FieldType.Textbox, HelpText = "User-Agent associated with cookie used from Browser")] public string UserAgent { get; set; }