New: Freeleech tokens support for Gazelle

This commit is contained in:
ta264
2021-01-12 21:13:20 +00:00
committed by Bogdan
parent 2351efd013
commit 2392573c39
2 changed files with 13 additions and 4 deletions
@@ -68,7 +68,7 @@ namespace NzbDrone.Core.Indexers.Gazelle
Container = torrent.Encoding, Container = torrent.Encoding,
Codec = torrent.Format, Codec = torrent.Format,
Size = long.Parse(torrent.Size), Size = long.Parse(torrent.Size),
DownloadUrl = GetDownloadUrl(id, _settings.AuthKey, _settings.PassKey), DownloadUrl = GetDownloadUrl(id),
InfoUrl = GetInfoUrl(result.GroupId, id), InfoUrl = GetInfoUrl(result.GroupId, id),
Seeders = int.Parse(torrent.Seeders), Seeders = int.Parse(torrent.Seeders),
Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders), Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders),
@@ -88,14 +88,20 @@ namespace NzbDrone.Core.Indexers.Gazelle
.ToArray(); .ToArray();
} }
private string GetDownloadUrl(int torrentId, string authKey, string passKey) private string GetDownloadUrl(int torrentId)
{ {
var url = new HttpUri(_settings.BaseUrl) var url = new HttpUri(_settings.BaseUrl)
.CombinePath("/torrents.php") .CombinePath("/torrents.php")
.AddQueryParam("action", "download") .AddQueryParam("action", "download")
.AddQueryParam("id", torrentId) .AddQueryParam("id", torrentId)
.AddQueryParam("authkey", authKey) .AddQueryParam("authkey", _settings.AuthKey)
.AddQueryParam("torrent_pass", passKey); .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; return url.FullUri;
} }
@@ -37,6 +37,9 @@ namespace NzbDrone.Core.Indexers.Gazelle
[FieldDefinition(2, Label = "Password", Type = FieldType.Password, HelpText = "Password", Privacy = PrivacyLevel.Password)] [FieldDefinition(2, Label = "Password", Type = FieldType.Password, HelpText = "Password", Privacy = PrivacyLevel.Password)]
public string Password { get; set; } 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)] [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; } public int? EarlyReleaseLimit { get; set; }