mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
This commit is contained in:
@@ -26,6 +26,7 @@ namespace Jackett.Common.Indexers.Abstract
|
||||
protected bool imdbInTags;
|
||||
protected bool supportsCategories = true; // set to false if the tracker doesn't include the categories in the API search results
|
||||
protected bool useTokens = false;
|
||||
protected string cookie = "";
|
||||
|
||||
private new ConfigurationDataBasicLogin configData
|
||||
{
|
||||
@@ -33,7 +34,7 @@ namespace Jackett.Common.Indexers.Abstract
|
||||
set { base.configData = value; }
|
||||
}
|
||||
|
||||
public GazelleTracker(IIndexerConfigurationService configService, Utils.Clients.WebClient webClient, Logger logger, IProtectionService protectionService, string name, string desc, string link, bool supportsFreeleechTokens, bool imdbInTags = false)
|
||||
public GazelleTracker(IIndexerConfigurationService configService, Utils.Clients.WebClient webClient, Logger logger, IProtectionService protectionService, string name, string desc, string link, bool supportsFreeleechTokens, bool imdbInTags = false, bool has2Fa = false)
|
||||
: base(name: name,
|
||||
description: desc,
|
||||
link: link,
|
||||
@@ -48,6 +49,19 @@ namespace Jackett.Common.Indexers.Abstract
|
||||
this.supportsFreeleechTokens = supportsFreeleechTokens;
|
||||
this.imdbInTags = imdbInTags;
|
||||
|
||||
if (has2Fa)
|
||||
{
|
||||
var cookieHint = new ConfigurationData.DisplayItem(
|
||||
"<ol><li>(use this only if 2FA is enabled for your account)</li><li>Login to this tracker with your browser<li>Open the <b>DevTools</b> panel by pressing <b>F12</b><li>Select the <b>Network</b> tab<li>Click on the <b>Doc</b> button<li>Refresh the page by pressing <b>F5</b><li>Select the <b>Headers</b> tab<li>Find 'cookie:' in the <b>Request Headers</b> section<li>Copy & paste the whole cookie string to here.</ol>")
|
||||
{
|
||||
Name = "CookieHint"
|
||||
};
|
||||
configData.AddDynamic("cookieHint", cookieHint);
|
||||
var cookieItem = new ConfigurationData.StringItem { Value = "" };
|
||||
cookieItem.Name = "Cookie";
|
||||
configData.AddDynamic("cookie", cookieItem);
|
||||
}
|
||||
|
||||
if (supportsFreeleechTokens)
|
||||
{
|
||||
var useTokenItem = new ConfigurationData.BoolItem { Value = false };
|
||||
@@ -60,11 +74,18 @@ namespace Jackett.Common.Indexers.Abstract
|
||||
{
|
||||
base.LoadValuesFromJson(jsonConfig, useProtectionService);
|
||||
|
||||
var cookieItem = (ConfigurationData.StringItem)configData.GetDynamic("cookie");
|
||||
if (cookieItem != null)
|
||||
{
|
||||
cookie = cookieItem.Value;
|
||||
}
|
||||
|
||||
var useTokenItem = (ConfigurationData.BoolItem)configData.GetDynamic("usetoken");
|
||||
if (useTokenItem != null)
|
||||
{
|
||||
useTokens = useTokenItem.Value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||
@@ -77,6 +98,29 @@ namespace Jackett.Common.Indexers.Abstract
|
||||
{ "keeplogged", "1"},
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(cookie))
|
||||
{
|
||||
// Cookie was manually supplied
|
||||
CookieHeader = cookie;
|
||||
try
|
||||
{
|
||||
var results = await PerformQuery(new TorznabQuery());
|
||||
if (!results.Any())
|
||||
{
|
||||
throw new Exception("Your cookie did not work");
|
||||
}
|
||||
|
||||
IsConfigured = true;
|
||||
SaveConfig();
|
||||
return IndexerConfigurationStatus.Completed;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
IsConfigured = false;
|
||||
throw new Exception("Your cookie did not work: " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
var response = await RequestLoginAndFollowRedirect(LoginUrl, pairs, string.Empty, true, SiteLink);
|
||||
await ConfigureIfOK(response.Cookies, response.Content != null && response.Content.Contains("logout.php"), () =>
|
||||
{
|
||||
|
@@ -17,7 +17,8 @@ namespace Jackett.Common.Indexers
|
||||
logger: logger,
|
||||
protectionService: protectionService,
|
||||
webClient: webClient,
|
||||
supportsFreeleechTokens: true
|
||||
supportsFreeleechTokens: true,
|
||||
has2Fa: true
|
||||
)
|
||||
{
|
||||
Language = "en-us";
|
||||
|
@@ -17,7 +17,8 @@ namespace Jackett.Common.Indexers
|
||||
logger: logger,
|
||||
protectionService: protectionService,
|
||||
webClient: webClient,
|
||||
supportsFreeleechTokens: true
|
||||
supportsFreeleechTokens: true,
|
||||
has2Fa: true
|
||||
)
|
||||
{
|
||||
Language = "en-us";
|
||||
|
Reference in New Issue
Block a user