From 4d129ada95dbfaa13582da55b03cf315fa5c66bf Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 22 Jun 2021 21:04:23 -0400 Subject: [PATCH] Fixed: (Gazelle) Not using freeleech token correctly Fixes #258 --- .../Definitions/Gazelle/GazelleParser.cs | 9 ++++--- .../Gazelle/GazelleRequestGenerator.cs | 2 -- .../Indexers/Definitions/Orpheus.cs | 27 ++++++++++++++++++- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/Definitions/Gazelle/GazelleParser.cs b/src/NzbDrone.Core/Indexers/Definitions/Gazelle/GazelleParser.cs index f6bf81afc..12af956e0 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Gazelle/GazelleParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Gazelle/GazelleParser.cs @@ -11,9 +11,9 @@ namespace NzbDrone.Core.Indexers.Gazelle { public class GazelleParser : IParseIndexerResponse { - private readonly GazelleSettings _settings; - private readonly IndexerCapabilities _capabilities; - private readonly string _baseUrl; + protected readonly GazelleSettings _settings; + protected readonly IndexerCapabilities _capabilities; + protected readonly string _baseUrl; public GazelleParser(GazelleSettings settings, IndexerCapabilities capabilities, string baseUrl) { @@ -138,11 +138,12 @@ namespace NzbDrone.Core.Indexers.Gazelle .ToArray(); } - private string GetDownloadUrl(int torrentId) + protected virtual string GetDownloadUrl(int torrentId) { var url = new HttpUri(_baseUrl) .CombinePath("/torrents.php") .AddQueryParam("action", "download") + .AddQueryParam("useToken", _settings.UseFreeleechToken ? "1" : "0") .AddQueryParam("id", torrentId); return url.FullUri; diff --git a/src/NzbDrone.Core/Indexers/Definitions/Gazelle/GazelleRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Definitions/Gazelle/GazelleRequestGenerator.cs index c10bfed36..0a156a1f5 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Gazelle/GazelleRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Gazelle/GazelleRequestGenerator.cs @@ -17,8 +17,6 @@ namespace NzbDrone.Core.Indexers.Gazelle public Logger Logger { get; set; } protected virtual string APIUrl => BaseUrl + "ajax.php"; - protected virtual string DownloadUrl => BaseUrl + "torrents.php?action=download&usetoken=" + (Settings.UseFreeleechToken ? "1" : "0") + "&id="; - protected virtual string DetailsUrl => BaseUrl + "torrents.php?torrentid="; protected virtual bool ImdbInTags => false; public Func> GetCookies { get; set; } diff --git a/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs b/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs index 9fb388ed6..75e95eb67 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Indexers.Gazelle; using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Indexers.Definitions @@ -49,5 +50,29 @@ namespace NzbDrone.Core.Indexers.Definitions return caps; } + + public override IParseIndexerResponse GetParser() + { + return new OrpheusParser(Settings, Capabilities, BaseUrl); + } + } + + public class OrpheusParser : GazelleParser + { + public OrpheusParser(GazelleSettings settings, IndexerCapabilities capabilities, string baseUrl) + : base(settings, capabilities, baseUrl) + { + } + + protected override string GetDownloadUrl(int torrentId) + { + var url = new HttpUri(_baseUrl) + .CombinePath("/ajax.php") + .AddQueryParam("action", "download") + .AddQueryParam("useToken", _settings.UseFreeleechToken ? "1" : "0") + .AddQueryParam("id", torrentId); + + return url.FullUri; + } } -} + }