From 2392573c39474391178cc057e1e54f7f83166193 Mon Sep 17 00:00:00 2001 From: ta264 Date: Tue, 12 Jan 2021 21:13:20 +0000 Subject: [PATCH] New: Freeleech tokens support for Gazelle --- .../Indexers/Gazelle/GazelleParser.cs | 14 ++++++++++---- .../Indexers/Gazelle/GazelleSettings.cs | 3 +++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/Gazelle/GazelleParser.cs b/src/NzbDrone.Core/Indexers/Gazelle/GazelleParser.cs index 3e7c67878..ed1f3fc2f 100644 --- a/src/NzbDrone.Core/Indexers/Gazelle/GazelleParser.cs +++ b/src/NzbDrone.Core/Indexers/Gazelle/GazelleParser.cs @@ -68,7 +68,7 @@ namespace NzbDrone.Core.Indexers.Gazelle Container = torrent.Encoding, Codec = torrent.Format, Size = long.Parse(torrent.Size), - DownloadUrl = GetDownloadUrl(id, _settings.AuthKey, _settings.PassKey), + DownloadUrl = GetDownloadUrl(id), InfoUrl = GetInfoUrl(result.GroupId, id), Seeders = int.Parse(torrent.Seeders), Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders), @@ -88,14 +88,20 @@ namespace NzbDrone.Core.Indexers.Gazelle .ToArray(); } - private string GetDownloadUrl(int torrentId, string authKey, string passKey) + private string GetDownloadUrl(int torrentId) { var url = new HttpUri(_settings.BaseUrl) .CombinePath("/torrents.php") .AddQueryParam("action", "download") .AddQueryParam("id", torrentId) - .AddQueryParam("authkey", authKey) - .AddQueryParam("torrent_pass", passKey); + .AddQueryParam("authkey", _settings.AuthKey) + .AddQueryParam("torrent_pass", _settings.PassKey); + + // Some trackers fail to download if usetoken=0 so we need to only add if we will use one + if (_settings.UseFreeleechToken) + { + url = url.AddQueryParam("usetoken", "1"); + } return url.FullUri; } diff --git a/src/NzbDrone.Core/Indexers/Gazelle/GazelleSettings.cs b/src/NzbDrone.Core/Indexers/Gazelle/GazelleSettings.cs index 9150e66dc..f9fe8602a 100644 --- a/src/NzbDrone.Core/Indexers/Gazelle/GazelleSettings.cs +++ b/src/NzbDrone.Core/Indexers/Gazelle/GazelleSettings.cs @@ -37,6 +37,9 @@ namespace NzbDrone.Core.Indexers.Gazelle [FieldDefinition(2, Label = "Password", Type = FieldType.Password, HelpText = "Password", Privacy = PrivacyLevel.Password)] public string Password { get; set; } + [FieldDefinition(3, Type = FieldType.Checkbox, Label = "Use Freeleech Token", HelpText = "Will cause grabbing to fail if you do not have any tokens available", Advanced = true)] + public bool UseFreeleechToken { get; set; } + [FieldDefinition(4, Type = FieldType.Number, Label = "Early Download Limit", Unit = "days", HelpText = "Time before release date Readarr will download from this indexer, empty is no limit", Advanced = true)] public int? EarlyReleaseLimit { get; set; }