mirror of https://github.com/Jackett/Jackett
gazelle: use tokens only for eligible releases (#15227)
This commit is contained in:
parent
f5bdba1dc7
commit
fc55a58309
|
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -265,6 +265,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)
|
||||
|
@ -280,15 +281,15 @@ namespace Jackett.Common.Indexers
|
|||
foreach (var tObj in JObject.FromObject(group["Torrents"]))
|
||||
{
|
||||
var torrent = tObj.Value as JObject;
|
||||
var torrentId = torrent.Value<string>("ID");
|
||||
var torrentId = torrent.Value<int>("ID");
|
||||
|
||||
if (categories.Length == 0)
|
||||
{
|
||||
categories = MapTrackerCatToNewznab(torrent.Value<string>("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<string>("ReleaseTitle"));
|
||||
var groupYear = group.Value<int>("year");
|
||||
|
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue