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

View file

@ -68,7 +68,7 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
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 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
.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;
}

View file

@ -37,6 +37,9 @@ public GazelleSettings()
[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; }