diff --git a/src/Jackett.Common/Indexers/Abstract/GazelleTracker.cs b/src/Jackett.Common/Indexers/Abstract/GazelleTracker.cs index 66d466e7f..c66e3beca 100644 --- a/src/Jackett.Common/Indexers/Abstract/GazelleTracker.cs +++ b/src/Jackett.Common/Indexers/Abstract/GazelleTracker.cs @@ -27,8 +27,6 @@ namespace Jackett.Common.Indexers.Abstract protected virtual string LoginUrl => SiteLink + "login.php"; protected virtual string APIUrl => SiteLink + "ajax.php"; - protected virtual string DownloadUrl => SiteLink + "torrents.php?action=download" + (useTokens ? "&usetoken=1" : "") + (usePassKey ? "&torrent_pass=" + configData.PassKey.Value : "") + (useAuthKey ? "&authkey=" + configData.AuthKey.Value : "") + "&id="; - protected virtual string DetailsUrl => SiteLink + "torrents.php?torrentid="; protected virtual string PosterUrl => SiteLink; protected virtual string AuthorizationName => "Authorization"; protected virtual string AuthorizationFormat => "{0}"; @@ -398,13 +396,13 @@ namespace Jackett.Common.Indexers.Abstract { var isFreeleech = bool.TryParse((string)torrent["isFreeleech"], out var freeleech) && freeleech; - // skip non-freeload results when freeload only is set + // skip non-freeleech results when freeleech only is set return configData.FreeleechOnly != null && configData.FreeleechOnly.Value && !isFreeleech; } protected void FillReleaseInfoFromJson(ReleaseInfo release, JObject torrent) { - var torrentId = torrent["torrentId"]; + var torrentId = (int)torrent["torrentId"]; var time = (string)torrent["time"]; if (!string.IsNullOrEmpty(time)) @@ -500,9 +498,10 @@ namespace Jackett.Common.Indexers.Abstract release.Size = (long)torrent["size"]; release.Seeders = (int)torrent["seeders"]; release.Peers = (int)torrent["leechers"] + release.Seeders; - release.Details = new Uri(DetailsUrl + torrentId); + release.Details = GetInfoUrl((int)torrent["groupId"], torrentId); release.Guid = release.Details; - release.Link = new Uri(DownloadUrl + torrentId); + release.Link = GetDownloadUrl(torrentId, release.DownloadVolumeFactor != 0); + var category = (string)torrent["category"]; if (category == null || category.Contains("Select Category")) { @@ -565,5 +564,15 @@ namespace Jackett.Common.Indexers.Abstract return content; } + + protected virtual Uri GetInfoUrl(int groupId, int torrentId) + { + return new Uri($"{SiteLink}torrents.php?id={groupId}&torrentid={torrentId}"); + } + + protected virtual Uri GetDownloadUrl(int torrentId, bool canUseToken) + { + return new Uri($"{SiteLink}torrents.php?action=download{(useTokens && canUseToken ? "&usetoken=1" : "")}{(usePassKey ? $"&torrent_pass={configData.PassKey.Value}" : "")}{(useAuthKey ? $"&authkey={configData.AuthKey.Value}" : "")}&id={torrentId}"); + } } } diff --git a/src/Jackett.Common/Indexers/GazelleGamesAPI.cs b/src/Jackett.Common/Indexers/GazelleGamesAPI.cs index 536be7598..aa0ae8343 100644 --- a/src/Jackett.Common/Indexers/GazelleGamesAPI.cs +++ b/src/Jackett.Common/Indexers/GazelleGamesAPI.cs @@ -255,6 +255,7 @@ namespace Jackett.Common.Indexers foreach (var gObj in JObject.FromObject(json["response"])) { + var groupId = int.Parse(gObj.Key); var group = gObj.Value as JObject; if (group["Torrents"].Type == JTokenType.Array && group["Torrents"] is JArray array && array.Count == 0) @@ -270,15 +271,15 @@ namespace Jackett.Common.Indexers foreach (var tObj in JObject.FromObject(group["Torrents"])) { var torrent = tObj.Value as JObject; - var torrentId = torrent.Value("ID"); + var torrentId = torrent.Value("ID"); if (categories.Length == 0) { categories = MapTrackerCatToNewznab(torrent.Value("CategoryID")).ToArray(); } - var details = new Uri(DetailsUrl + torrentId); - var link = new Uri(DownloadUrl + torrentId); + var details = GetInfoUrl(groupId, torrentId); + var link = GetDownloadUrl(torrentId, false); var title = WebUtility.HtmlDecode(torrent.Value("ReleaseTitle")); var groupYear = group.Value("year"); diff --git a/src/Jackett.Common/Indexers/Orpheus.cs b/src/Jackett.Common/Indexers/Orpheus.cs index bf0ba8439..4f693cec0 100644 --- a/src/Jackett.Common/Indexers/Orpheus.cs +++ b/src/Jackett.Common/Indexers/Orpheus.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -24,7 +25,6 @@ namespace Jackett.Common.Indexers public override TorznabCapabilities TorznabCaps => SetCapabilities(); // API Reference: https://github.com/OPSnet/Gazelle/wiki/JSON-API-Documentation - protected override string DownloadUrl => SiteLink + "ajax.php?action=download" + (useTokens ? "&usetoken=1" : "") + "&id="; protected override string AuthorizationFormat => "token {0}"; protected override int ApiKeyLength => 116; protected override int ApiKeyLengthLegacy => 118; @@ -69,5 +69,10 @@ namespace Jackett.Common.Indexers return caps; } + + protected override Uri GetDownloadUrl(int torrentId, bool canUseToken) + { + return new Uri($"{SiteLink}ajax.php?action=download{(useTokens && canUseToken ? "&usetoken=1" : "")}&id={torrentId}"); + } } } diff --git a/src/Jackett.Common/Indexers/Redacted.cs b/src/Jackett.Common/Indexers/Redacted.cs index dd3748d57..4767694f5 100644 --- a/src/Jackett.Common/Indexers/Redacted.cs +++ b/src/Jackett.Common/Indexers/Redacted.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -24,8 +25,6 @@ namespace Jackett.Common.Indexers public override TorznabCapabilities TorznabCaps => SetCapabilities(); - protected override string DownloadUrl => SiteLink + "ajax.php?action=download" + (useTokens ? "&usetoken=1" : "") + "&id="; - public Redacted(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps, ICacheService cs) : base(configService: configService, client: wc, @@ -93,5 +92,10 @@ namespace Jackett.Common.Indexers return base.ShouldSkipRelease(torrent); } + + protected override Uri GetDownloadUrl(int torrentId, bool canUseToken) + { + return new Uri($"{SiteLink}ajax.php?action=download{(useTokens && canUseToken ? "&usetoken=1" : "")}&id={torrentId}"); + } } } diff --git a/src/Jackett.Common/Indexers/iAnon.cs b/src/Jackett.Common/Indexers/iAnon.cs index 74423674b..fb5a20fd8 100644 --- a/src/Jackett.Common/Indexers/iAnon.cs +++ b/src/Jackett.Common/Indexers/iAnon.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using Jackett.Common.Indexers.Abstract; @@ -21,7 +22,6 @@ namespace Jackett.Common.Indexers public override TorznabCapabilities TorznabCaps => SetCapabilities(); - protected override string DownloadUrl => SiteLink + "ajax.php?action=download" + (useTokens ? "&usetoken=1" : "") + "&id="; protected override string AuthorizationFormat => "token {0}"; protected override int ApiKeyLength => 118; @@ -62,5 +62,10 @@ namespace Jackett.Common.Indexers return caps; } + + protected override Uri GetDownloadUrl(int torrentId, bool canUseToken) + { + return new Uri($"{SiteLink}ajax.php?action=download{(useTokens && canUseToken ? "&usetoken=1" : "")}&id={torrentId}"); + } } }