From f652371966b9675505da342b9969c3f71250a84d Mon Sep 17 00:00:00 2001 From: Florian Duguet Date: Mon, 21 Jan 2019 18:10:49 +0100 Subject: [PATCH] Manage funcaptcha Add FuncaptchaQuestion and FuncaptchaJob to manage funcaptcha --- weboob/capabilities/captcha.py | 13 ++++++++++++- weboob/exceptions.py | 12 ++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/weboob/capabilities/captcha.py b/weboob/capabilities/captcha.py index b3c84f1c5f..79faa08f33 100644 --- a/weboob/capabilities/captcha.py +++ b/weboob/capabilities/captcha.py @@ -20,7 +20,7 @@ from time import sleep from .base import Capability, BaseObject, StringField, UserError, BytesField -from ..exceptions import RecaptchaQuestion, NocaptchaQuestion, ImageCaptchaQuestion +from ..exceptions import RecaptchaQuestion, NocaptchaQuestion, FuncaptchaQuestion, ImageCaptchaQuestion __all__ = [ @@ -47,6 +47,12 @@ class NocaptchaJob(SolverJob): site_key = StringField('Site key for NoCaptcha service') +class FuncaptchaJob(SolverJob): + site_url = StringField('Site URL for FunCaptcha service') + site_key = StringField('Site key for FunCaptcha service') + sub_domain = StringField('Required for some complex cases, but Funcaptcha integrations run without it') + + class ImageCaptchaJob(SolverJob): image = BytesField('data of the image to solve') @@ -76,6 +82,11 @@ def exception_to_job(exc): job = NocaptchaJob() job.site_url = exc.website_url job.site_key = exc.website_key + elif isinstance(exc, FuncaptchaQuestion): + job = FuncaptchaJob() + job.site_url = exc.website_url + job.site_key = exc.website_key + job.sub_domain = exc.sub_domain elif isinstance(exc, ImageCaptchaQuestion): job = ImageCaptchaJob() job.image = exc.image_data diff --git a/weboob/exceptions.py b/weboob/exceptions.py index 07b634dca4..9bd19191fb 100644 --- a/weboob/exceptions.py +++ b/weboob/exceptions.py @@ -93,6 +93,18 @@ def __init__(self, website_key, website_url): super(RecaptchaQuestion, self).__init__(self.type, website_key=website_key, website_url=website_url) +class FuncaptchaQuestion(CaptchaQuestion): + type = 'funcaptcha' + + website_key = None + website_url = None + sub_domain = None + + def __init__(self, website_key, website_url, sub_domain=None): + super(FuncaptchaQuestion, self).__init__( + self.type, website_key=website_key, website_url=website_url, sub_domain=sub_domain) + + class BrowserHTTPNotFound(BrowserUnavailable): pass -- GitLab