mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Cardigann: don't try to re-login in case of a captcha
This commit is contained in:
@@ -370,7 +370,7 @@ namespace Jackett.Indexers
|
|||||||
var Login = Definition.Login;
|
var Login = Definition.Login;
|
||||||
|
|
||||||
if (Login == null)
|
if (Login == null)
|
||||||
return false;
|
return true;
|
||||||
|
|
||||||
if (Login.Method == "post")
|
if (Login.Method == "post")
|
||||||
{
|
{
|
||||||
@@ -441,7 +441,11 @@ namespace Jackett.Indexers
|
|||||||
// landingResultDocument might not be initiated if the login is caused by a relogin during a query
|
// landingResultDocument might not be initiated if the login is caused by a relogin during a query
|
||||||
if (landingResultDocument == null)
|
if (landingResultDocument == null)
|
||||||
{
|
{
|
||||||
await GetConfigurationForSetup();
|
var ConfigurationResult = await GetConfigurationForSetup(true);
|
||||||
|
if (ConfigurationResult == null) // got captcha
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var form = landingResultDocument.QuerySelector(FormSelector);
|
var form = landingResultDocument.QuerySelector(FormSelector);
|
||||||
@@ -650,6 +654,11 @@ namespace Jackett.Indexers
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<ConfigurationData> GetConfigurationForSetup()
|
public override async Task<ConfigurationData> GetConfigurationForSetup()
|
||||||
|
{
|
||||||
|
return await GetConfigurationForSetup(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ConfigurationData> GetConfigurationForSetup(bool automaticlogin)
|
||||||
{
|
{
|
||||||
var Login = Definition.Login;
|
var Login = Definition.Login;
|
||||||
|
|
||||||
@@ -664,9 +673,12 @@ namespace Jackett.Indexers
|
|||||||
var htmlParser = new HtmlParser();
|
var htmlParser = new HtmlParser();
|
||||||
landingResultDocument = htmlParser.Parse(landingResult.Content);
|
landingResultDocument = htmlParser.Parse(landingResult.Content);
|
||||||
|
|
||||||
|
var hasCaptcha = false;
|
||||||
|
|
||||||
var grecaptcha = landingResultDocument.QuerySelector(".g-recaptcha");
|
var grecaptcha = landingResultDocument.QuerySelector(".g-recaptcha");
|
||||||
if (grecaptcha != null)
|
if (grecaptcha != null)
|
||||||
{
|
{
|
||||||
|
hasCaptcha = true;
|
||||||
var CaptchaItem = new RecaptchaItem();
|
var CaptchaItem = new RecaptchaItem();
|
||||||
CaptchaItem.Name = "Captcha";
|
CaptchaItem.Name = "Captcha";
|
||||||
CaptchaItem.Version = "2";
|
CaptchaItem.Version = "2";
|
||||||
@@ -684,6 +696,8 @@ namespace Jackett.Indexers
|
|||||||
{
|
{
|
||||||
var captchaElement = landingResultDocument.QuerySelector(Captcha.Image);
|
var captchaElement = landingResultDocument.QuerySelector(Captcha.Image);
|
||||||
if (captchaElement != null) {
|
if (captchaElement != null) {
|
||||||
|
hasCaptcha = true;
|
||||||
|
|
||||||
var CaptchaUrl = resolvePath(captchaElement.GetAttribute("src"));
|
var CaptchaUrl = resolvePath(captchaElement.GetAttribute("src"));
|
||||||
var captchaImageData = await RequestBytesWithCookies(CaptchaUrl.ToString(), landingResult.Cookies, RequestType.GET, LoginUrl.ToString());
|
var captchaImageData = await RequestBytesWithCookies(CaptchaUrl.ToString(), landingResult.Cookies, RequestType.GET, LoginUrl.ToString());
|
||||||
var CaptchaImage = new ImageItem { Name = "Captcha Image" };
|
var CaptchaImage = new ImageItem { Name = "Captcha Image" };
|
||||||
@@ -705,6 +719,13 @@ namespace Jackett.Indexers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasCaptcha && automaticlogin)
|
||||||
|
{
|
||||||
|
configData.LastError.Value = "Got captcha during automatic login, please reconfigure manually";
|
||||||
|
logger.Error(string.Format("CardigannIndexer ({0}): Found captcha during automatic login, aborting", ID));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return configData;
|
return configData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -977,7 +998,9 @@ namespace Jackett.Indexers
|
|||||||
if (loginNeeded)
|
if (loginNeeded)
|
||||||
{
|
{
|
||||||
logger.Info(string.Format("CardigannIndexer ({0}): Relogin required", ID));
|
logger.Info(string.Format("CardigannIndexer ({0}): Relogin required", ID));
|
||||||
await DoLogin();
|
var LoginResult = await DoLogin();
|
||||||
|
if (!LoginResult)
|
||||||
|
throw new Exception(string.Format("Relogin failed"));
|
||||||
await TestLogin();
|
await TestLogin();
|
||||||
response = await RequestStringWithCookies(searchUrl);
|
response = await RequestStringWithCookies(searchUrl);
|
||||||
results = results = response.Content;
|
results = results = response.Content;
|
||||||
|
Reference in New Issue
Block a user