mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Cardigann: add support for text captcha
This commit is contained in:
@@ -42,7 +42,7 @@
|
|||||||
pwd: "{{ .Config.password }}"
|
pwd: "{{ .Config.password }}"
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img.captcha
|
selector: img.captcha
|
||||||
input: private_key
|
input: private_key
|
||||||
error:
|
error:
|
||||||
- selector: span.errormsg
|
- selector: span.errormsg
|
||||||
|
@@ -65,7 +65,7 @@
|
|||||||
form: form#login
|
form: form#login
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img[alt="Security code"]
|
selector: img[alt="Security code"]
|
||||||
input: code
|
input: code
|
||||||
inputs:
|
inputs:
|
||||||
username: "{{ .Config.username }}"
|
username: "{{ .Config.username }}"
|
||||||
|
@@ -50,7 +50,7 @@
|
|||||||
form: form[action="takelogin.php"]
|
form: form[action="takelogin.php"]
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img[src="visual.php"]
|
selector: img[src="visual.php"]
|
||||||
input: secimage
|
input: secimage
|
||||||
inputs:
|
inputs:
|
||||||
username: "{{ .Config.username }}"
|
username: "{{ .Config.username }}"
|
||||||
|
@@ -92,7 +92,7 @@
|
|||||||
cookies: ["JAVA=OK"] # avoid jscheck redirect
|
cookies: ["JAVA=OK"] # avoid jscheck redirect
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img[src^="cap/captcha_math.php"]
|
selector: img[src^="cap/captcha_math.php"]
|
||||||
input: stringCaptcha
|
input: stringCaptcha
|
||||||
inputs:
|
inputs:
|
||||||
username: "{{ .Config.username }}"
|
username: "{{ .Config.username }}"
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
form: form[action="takelogin.php"]
|
form: form[action="takelogin.php"]
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img#captcha
|
selector: img#captcha
|
||||||
input: imagestring
|
input: imagestring
|
||||||
inputs:
|
inputs:
|
||||||
username: "{{ .Config.username }}"
|
username: "{{ .Config.username }}"
|
||||||
|
@@ -46,7 +46,7 @@
|
|||||||
form: form[action="login3.php?takelogin=1"]
|
form: form[action="login3.php?takelogin=1"]
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img#validationimage
|
selector: img#validationimage
|
||||||
input: validationcode
|
input: validationcode
|
||||||
inputs:
|
inputs:
|
||||||
username: "{{ .Config.username }}"
|
username: "{{ .Config.username }}"
|
||||||
|
@@ -51,7 +51,7 @@
|
|||||||
password: "{{ .Config.password }}"
|
password: "{{ .Config.password }}"
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img[alt="CAPTCHA"]
|
selector: img[alt="CAPTCHA"]
|
||||||
input: imagestring
|
input: imagestring
|
||||||
error:
|
error:
|
||||||
- selector: td.embedded:has(h2:contains("failed"))
|
- selector: td.embedded:has(h2:contains("failed"))
|
||||||
|
@@ -67,7 +67,7 @@
|
|||||||
form: form[action="takelogin.php"]
|
form: form[action="takelogin.php"]
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img[alt="CAPTCHA"]
|
selector: img[alt="CAPTCHA"]
|
||||||
input: imagestring
|
input: imagestring
|
||||||
inputs:
|
inputs:
|
||||||
logintype: "username"
|
logintype: "username"
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
form: form[action="takelogin.php"]
|
form: form[action="takelogin.php"]
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img[alt="CAPTCHA"]
|
selector: img[alt="CAPTCHA"]
|
||||||
input: imagestring
|
input: imagestring
|
||||||
inputs:
|
inputs:
|
||||||
username: "{{ .Config.username }}"
|
username: "{{ .Config.username }}"
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
password: "{{ .Config.password }}"
|
password: "{{ .Config.password }}"
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img#captcha_img
|
selector: img#captcha_img
|
||||||
input: imagestring
|
input: imagestring
|
||||||
error:
|
error:
|
||||||
- selector: table:contains("Login failed!")
|
- selector: table:contains("Login failed!")
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
form: form[action="takelogin.php"]
|
form: form[action="takelogin.php"]
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img[src="img.php"]
|
selector: img[src="img.php"]
|
||||||
input: vImageCodP
|
input: vImageCodP
|
||||||
inputs:
|
inputs:
|
||||||
username: "{{ .Config.username }}"
|
username: "{{ .Config.username }}"
|
||||||
|
@@ -58,7 +58,7 @@
|
|||||||
password: "{{ .Config.password }}"
|
password: "{{ .Config.password }}"
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img#freecap
|
selector: img#freecap
|
||||||
input: word
|
input: word
|
||||||
error:
|
error:
|
||||||
- selector: table:contains("Login failed!")
|
- selector: table:contains("Login failed!")
|
||||||
|
@@ -92,7 +92,7 @@
|
|||||||
password: "{{ .Config.password }}"
|
password: "{{ .Config.password }}"
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img#freecap
|
selector: img#freecap
|
||||||
input: word
|
input: word
|
||||||
error:
|
error:
|
||||||
- selector: table:contains("Login failed!")
|
- selector: table:contains("Login failed!")
|
||||||
|
@@ -74,7 +74,7 @@
|
|||||||
password: "{{ .Config.password }}"
|
password: "{{ .Config.password }}"
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img#freecap
|
selector: img#freecap
|
||||||
input: word
|
input: word
|
||||||
error:
|
error:
|
||||||
- selector: table:contains("Login failed!")
|
- selector: table:contains("Login failed!")
|
||||||
|
@@ -57,7 +57,7 @@
|
|||||||
password: "{{ .Config.password }}"
|
password: "{{ .Config.password }}"
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img#freecap
|
selector: img#freecap
|
||||||
input: word
|
input: word
|
||||||
error:
|
error:
|
||||||
- selector: table:contains("Login failed!")
|
- selector: table:contains("Login failed!")
|
||||||
|
@@ -72,7 +72,7 @@
|
|||||||
password: "{{ .Config.password }}"
|
password: "{{ .Config.password }}"
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img#freecap
|
selector: img#freecap
|
||||||
input: word
|
input: word
|
||||||
error:
|
error:
|
||||||
- selector: table:contains("Login failed!")
|
- selector: table:contains("Login failed!")
|
||||||
|
@@ -73,7 +73,7 @@
|
|||||||
password: "{{ .Config.password }}"
|
password: "{{ .Config.password }}"
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img#freecap
|
selector: img#freecap
|
||||||
input: word
|
input: word
|
||||||
error:
|
error:
|
||||||
- selector: table:contains("Login failed!")
|
- selector: table:contains("Login failed!")
|
||||||
|
@@ -43,7 +43,7 @@
|
|||||||
form: form[action="takelogin.php"]
|
form: form[action="takelogin.php"]
|
||||||
captcha:
|
captcha:
|
||||||
type: image
|
type: image
|
||||||
image: img[alt="CAPTCHA"]
|
selector: img[alt="CAPTCHA"]
|
||||||
input: imagestring
|
input: imagestring
|
||||||
inputs:
|
inputs:
|
||||||
username: "{{ .Config.username }}"
|
username: "{{ .Config.username }}"
|
||||||
|
@@ -557,6 +557,22 @@ namespace Jackett.Indexers
|
|||||||
pairs[input] = CaptchaText.Value;
|
pairs[input] = CaptchaText.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (Captcha.Type == "text")
|
||||||
|
{
|
||||||
|
var CaptchaAnswer = (StringItem)configData.GetDynamic("CaptchaAnswer");
|
||||||
|
if (CaptchaAnswer != null)
|
||||||
|
{
|
||||||
|
var input = Captcha.Input;
|
||||||
|
if (Login.Selectors)
|
||||||
|
{
|
||||||
|
var inputElement = landingResultDocument.QuerySelector(Captcha.Input);
|
||||||
|
if (inputElement == null)
|
||||||
|
throw new ExceptionWithConfigData(string.Format("Login failed: No captcha input found using {0}", Captcha.Input), configData);
|
||||||
|
input = inputElement.GetAttribute("name");
|
||||||
|
}
|
||||||
|
pairs[input] = CaptchaAnswer.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear landingResults/Document, otherwise we might use an old version for a new relogin (if GetConfigurationForSetup() wasn't called before)
|
// clear landingResults/Document, otherwise we might use an old version for a new relogin (if GetConfigurationForSetup() wasn't called before)
|
||||||
@@ -716,7 +732,7 @@ namespace Jackett.Indexers
|
|||||||
var Captcha = Login.Captcha;
|
var Captcha = Login.Captcha;
|
||||||
if (Captcha.Type == "image")
|
if (Captcha.Type == "image")
|
||||||
{
|
{
|
||||||
var captchaElement = landingResultDocument.QuerySelector(Captcha.Image);
|
var captchaElement = landingResultDocument.QuerySelector(Captcha.Selector);
|
||||||
if (captchaElement != null)
|
if (captchaElement != null)
|
||||||
{
|
{
|
||||||
hasCaptcha = true;
|
hasCaptcha = true;
|
||||||
@@ -736,6 +752,24 @@ namespace Jackett.Indexers
|
|||||||
logger.Debug(string.Format("CardigannIndexer ({0}): No captcha image found", ID));
|
logger.Debug(string.Format("CardigannIndexer ({0}): No captcha image found", ID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (Captcha.Type == "text")
|
||||||
|
{
|
||||||
|
var captchaElement = landingResultDocument.QuerySelector(Captcha.Selector);
|
||||||
|
if (captchaElement != null)
|
||||||
|
{
|
||||||
|
hasCaptcha = true;
|
||||||
|
|
||||||
|
var CaptchaChallenge = new DisplayItem(captchaElement.TextContent) { Name = "Captcha Challenge" };
|
||||||
|
var CaptchaAnswer = new StringItem { Name = "Captcha Answer" };
|
||||||
|
|
||||||
|
configData.AddDynamic("CaptchaChallenge", CaptchaChallenge);
|
||||||
|
configData.AddDynamic("CaptchaAnswer", CaptchaAnswer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.Debug(string.Format("CardigannIndexer ({0}): No captcha image found", ID));
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new NotImplementedException(string.Format("Captcha type \"{0}\" is not implemented", Captcha.Type));
|
throw new NotImplementedException(string.Format("Captcha type \"{0}\" is not implemented", Captcha.Type));
|
||||||
|
@@ -102,7 +102,8 @@ namespace Jackett.Models
|
|||||||
public class captchaBlock
|
public class captchaBlock
|
||||||
{
|
{
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
public string Image { get; set; }
|
public string Selector { get; set; }
|
||||||
|
public string Image { get { throw new Exception("Deprecated, please use Login.Captcha.Selector instead"); } set { throw new Exception("Deprecated, please use login/captcha/selector instead of image"); } }
|
||||||
public string Input { get; set; }
|
public string Input { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user