Cardigann: automatically solve simpleCaptchas (#710)

This commit is contained in:
kaso17 2016-11-20 11:24:29 +01:00 committed by GitHub
parent 3aecc53b5f
commit 5a4c1282ef
1 changed files with 13 additions and 1 deletions

View File

@ -370,7 +370,19 @@ namespace Jackett.Indexers
var value = applyGoTemplateText(Input.Value); var value = applyGoTemplateText(Input.Value);
pairs[Input.Key] = value; pairs[Input.Key] = value;
} }
// automatically solve simpleCaptchas, if used
var simpleCaptchaPresent = landingResultDocument.QuerySelector("script[src*=\"simpleCaptcha\"]");
if(simpleCaptchaPresent != null)
{
var captchaUrl = resolvePath("simpleCaptcha.php?numImages=1");
var simpleCaptchaResult = await RequestStringWithCookies(captchaUrl.ToString(), landingResult.Cookies, LoginUrl);
var simpleCaptchaJSON = JObject.Parse(simpleCaptchaResult.Content);
var captchaSelection = simpleCaptchaJSON["images"][0]["hash"].ToString();
pairs["captchaSelection"] = captchaSelection;
pairs["submitme"] = "X";
}
var loginResult = await RequestLoginAndFollowRedirect(submitUrl.ToString(), pairs, landingResult.Cookies, true, null, SiteLink, true); var loginResult = await RequestLoginAndFollowRedirect(submitUrl.ToString(), pairs, landingResult.Cookies, true, null, SiteLink, true);
configData.CookieHeader.Value = loginResult.Cookies; configData.CookieHeader.Value = loginResult.Cookies;