diff --git a/src/Jackett.Common/Definitions/3dtorrents.yml b/src/Jackett.Common/Definitions/3dtorrents.yml index c75f1dae8..10ce8bf02 100644 --- a/src/Jackett.Common/Definitions/3dtorrents.yml +++ b/src/Jackett.Common/Definitions/3dtorrents.yml @@ -42,7 +42,7 @@ pwd: "{{ .Config.password }}" captcha: type: image - image: img.captcha + selector: img.captcha input: private_key error: - selector: span.errormsg diff --git a/src/Jackett.Common/Definitions/acidlounge.yml b/src/Jackett.Common/Definitions/acidlounge.yml index 782b54fcb..59f70ebd7 100644 --- a/src/Jackett.Common/Definitions/acidlounge.yml +++ b/src/Jackett.Common/Definitions/acidlounge.yml @@ -65,7 +65,7 @@ form: form#login captcha: type: image - image: img[alt="Security code"] + selector: img[alt="Security code"] input: code inputs: username: "{{ .Config.username }}" diff --git a/src/Jackett.Common/Definitions/bitme.yml b/src/Jackett.Common/Definitions/bitme.yml index ada7dc887..173b86b0c 100644 --- a/src/Jackett.Common/Definitions/bitme.yml +++ b/src/Jackett.Common/Definitions/bitme.yml @@ -50,7 +50,7 @@ form: form[action="takelogin.php"] captcha: type: image - image: img[src="visual.php"] + selector: img[src="visual.php"] input: secimage inputs: username: "{{ .Config.username }}" diff --git a/src/Jackett.Common/Definitions/dragonworldreloaded.yml b/src/Jackett.Common/Definitions/dragonworldreloaded.yml index a9021580b..abc93add2 100644 --- a/src/Jackett.Common/Definitions/dragonworldreloaded.yml +++ b/src/Jackett.Common/Definitions/dragonworldreloaded.yml @@ -92,7 +92,7 @@ cookies: ["JAVA=OK"] # avoid jscheck redirect captcha: type: image - image: img[src^="cap/captcha_math.php"] + selector: img[src^="cap/captcha_math.php"] input: stringCaptcha inputs: username: "{{ .Config.username }}" diff --git a/src/Jackett.Common/Definitions/elitehd.yml b/src/Jackett.Common/Definitions/elitehd.yml index fdb4a51cf..8e3006109 100644 --- a/src/Jackett.Common/Definitions/elitehd.yml +++ b/src/Jackett.Common/Definitions/elitehd.yml @@ -29,7 +29,7 @@ form: form[action="takelogin.php"] captcha: type: image - image: img#captcha + selector: img#captcha input: imagestring inputs: username: "{{ .Config.username }}" diff --git a/src/Jackett.Common/Definitions/ethor.yml b/src/Jackett.Common/Definitions/ethor.yml index 464faa041..876bf08d4 100644 --- a/src/Jackett.Common/Definitions/ethor.yml +++ b/src/Jackett.Common/Definitions/ethor.yml @@ -46,7 +46,7 @@ form: form[action="login3.php?takelogin=1"] captcha: type: image - image: img#validationimage + selector: img#validationimage input: validationcode inputs: username: "{{ .Config.username }}" diff --git a/src/Jackett.Common/Definitions/hdchina.yml b/src/Jackett.Common/Definitions/hdchina.yml index bc254c19e..1384ba16f 100644 --- a/src/Jackett.Common/Definitions/hdchina.yml +++ b/src/Jackett.Common/Definitions/hdchina.yml @@ -51,7 +51,7 @@ password: "{{ .Config.password }}" captcha: type: image - image: img[alt="CAPTCHA"] + selector: img[alt="CAPTCHA"] input: imagestring error: - selector: td.embedded:has(h2:contains("failed")) diff --git a/src/Jackett.Common/Definitions/hdhome.yml b/src/Jackett.Common/Definitions/hdhome.yml index fee76fa11..d4c733e0e 100644 --- a/src/Jackett.Common/Definitions/hdhome.yml +++ b/src/Jackett.Common/Definitions/hdhome.yml @@ -67,7 +67,7 @@ form: form[action="takelogin.php"] captcha: type: image - image: img[alt="CAPTCHA"] + selector: img[alt="CAPTCHA"] input: imagestring inputs: logintype: "username" diff --git a/src/Jackett.Common/Definitions/hdsky.yml b/src/Jackett.Common/Definitions/hdsky.yml index 841fb517b..652d08b9a 100644 --- a/src/Jackett.Common/Definitions/hdsky.yml +++ b/src/Jackett.Common/Definitions/hdsky.yml @@ -32,7 +32,7 @@ form: form[action="takelogin.php"] captcha: type: image - image: img[alt="CAPTCHA"] + selector: img[alt="CAPTCHA"] input: imagestring inputs: username: "{{ .Config.username }}" diff --git a/src/Jackett.Common/Definitions/karagarga.yml b/src/Jackett.Common/Definitions/karagarga.yml index 1e0e87364..2fdd6b4aa 100644 --- a/src/Jackett.Common/Definitions/karagarga.yml +++ b/src/Jackett.Common/Definitions/karagarga.yml @@ -23,7 +23,7 @@ password: "{{ .Config.password }}" captcha: type: image - image: img#captcha_img + selector: img#captcha_img input: imagestring error: - selector: table:contains("Login failed!") diff --git a/src/Jackett.Common/Definitions/polishsource.yml b/src/Jackett.Common/Definitions/polishsource.yml index 8bf6494f5..5f7364b8d 100644 --- a/src/Jackett.Common/Definitions/polishsource.yml +++ b/src/Jackett.Common/Definitions/polishsource.yml @@ -35,7 +35,7 @@ form: form[action="takelogin.php"] captcha: type: image - image: img[src="img.php"] + selector: img[src="img.php"] input: vImageCodP inputs: username: "{{ .Config.username }}" diff --git a/src/Jackett.Common/Definitions/theempire.yml b/src/Jackett.Common/Definitions/theempire.yml index e7bde4be4..3b6ffc17d 100644 --- a/src/Jackett.Common/Definitions/theempire.yml +++ b/src/Jackett.Common/Definitions/theempire.yml @@ -58,7 +58,7 @@ password: "{{ .Config.password }}" captcha: type: image - image: img#freecap + selector: img#freecap input: word error: - selector: table:contains("Login failed!") diff --git a/src/Jackett.Common/Definitions/thegeeks.yml b/src/Jackett.Common/Definitions/thegeeks.yml index abf0ba58e..6de0569b8 100644 --- a/src/Jackett.Common/Definitions/thegeeks.yml +++ b/src/Jackett.Common/Definitions/thegeeks.yml @@ -92,7 +92,7 @@ password: "{{ .Config.password }}" captcha: type: image - image: img#freecap + selector: img#freecap input: word error: - selector: table:contains("Login failed!") diff --git a/src/Jackett.Common/Definitions/theoccult.yml b/src/Jackett.Common/Definitions/theoccult.yml index 2bb0fe7b5..38a4a963c 100644 --- a/src/Jackett.Common/Definitions/theoccult.yml +++ b/src/Jackett.Common/Definitions/theoccult.yml @@ -74,7 +74,7 @@ password: "{{ .Config.password }}" captcha: type: image - image: img#freecap + selector: img#freecap input: word error: - selector: table:contains("Login failed!") diff --git a/src/Jackett.Common/Definitions/theplace.yml b/src/Jackett.Common/Definitions/theplace.yml index 0d3d21008..84051b954 100644 --- a/src/Jackett.Common/Definitions/theplace.yml +++ b/src/Jackett.Common/Definitions/theplace.yml @@ -57,7 +57,7 @@ password: "{{ .Config.password }}" captcha: type: image - image: img#freecap + selector: img#freecap input: word error: - selector: table:contains("Login failed!") diff --git a/src/Jackett.Common/Definitions/theshow.yml b/src/Jackett.Common/Definitions/theshow.yml index 1991ebb50..baaeba67b 100644 --- a/src/Jackett.Common/Definitions/theshow.yml +++ b/src/Jackett.Common/Definitions/theshow.yml @@ -72,7 +72,7 @@ password: "{{ .Config.password }}" captcha: type: image - image: img#freecap + selector: img#freecap input: word error: - selector: table:contains("Login failed!") diff --git a/src/Jackett.Common/Definitions/thevault.yml b/src/Jackett.Common/Definitions/thevault.yml index 9197a4118..66abad6ab 100644 --- a/src/Jackett.Common/Definitions/thevault.yml +++ b/src/Jackett.Common/Definitions/thevault.yml @@ -73,7 +73,7 @@ password: "{{ .Config.password }}" captcha: type: image - image: img#freecap + selector: img#freecap input: word error: - selector: table:contains("Login failed!") diff --git a/src/Jackett.Common/Definitions/torrentccf.yml b/src/Jackett.Common/Definitions/torrentccf.yml index 077077983..60a9246c0 100644 --- a/src/Jackett.Common/Definitions/torrentccf.yml +++ b/src/Jackett.Common/Definitions/torrentccf.yml @@ -43,7 +43,7 @@ form: form[action="takelogin.php"] captcha: type: image - image: img[alt="CAPTCHA"] + selector: img[alt="CAPTCHA"] input: imagestring inputs: username: "{{ .Config.username }}" diff --git a/src/Jackett.Common/Indexers/CardigannIndexer.cs b/src/Jackett.Common/Indexers/CardigannIndexer.cs index 496024015..5fb1230f0 100644 --- a/src/Jackett.Common/Indexers/CardigannIndexer.cs +++ b/src/Jackett.Common/Indexers/CardigannIndexer.cs @@ -557,6 +557,22 @@ namespace Jackett.Indexers 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) @@ -716,7 +732,7 @@ namespace Jackett.Indexers var Captcha = Login.Captcha; if (Captcha.Type == "image") { - var captchaElement = landingResultDocument.QuerySelector(Captcha.Image); + var captchaElement = landingResultDocument.QuerySelector(Captcha.Selector); if (captchaElement != null) { hasCaptcha = true; @@ -736,6 +752,24 @@ namespace Jackett.Indexers 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 { throw new NotImplementedException(string.Format("Captcha type \"{0}\" is not implemented", Captcha.Type)); diff --git a/src/Jackett.Common/Models/IndexerDefinition.cs b/src/Jackett.Common/Models/IndexerDefinition.cs index 7574c84ed..87e184013 100644 --- a/src/Jackett.Common/Models/IndexerDefinition.cs +++ b/src/Jackett.Common/Models/IndexerDefinition.cs @@ -102,7 +102,8 @@ namespace Jackett.Models public class captchaBlock { 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; } }