diff --git a/tools/stable_backport_data/weboob_exceptions.py b/tools/stable_backport_data/weboob_exceptions.py index 0db9fb13f2e2e63bd036bbbf35c683cd376a7095..e1912dfbf13e2acd7d6a676b5765d962a734925f 100644 --- a/tools/stable_backport_data/weboob_exceptions.py +++ b/tools/stable_backport_data/weboob_exceptions.py @@ -7,4 +7,40 @@ class AuthMethodNotImplemented(Exception): class CaptchaQuestion(Exception): - pass + """Site requires solving a CAPTCHA (base class)""" + # could be improved to pass the name of the backendconfig key + + def __init__(self, type=None, **kwargs): + super(CaptchaQuestion, self).__init__("The site requires solving a captcha") + self.type = type + for key, value in kwargs.items(): + setattr(self, key, value) + + +class ImageCaptchaQuestion(CaptchaQuestion): + type = 'image_captcha' + + image_data = None + + def __init__(self, image_data): + super(ImageCaptchaQuestion, self).__init__(self.type, image_data=image_data) + + +class NocaptchaQuestion(CaptchaQuestion): + type = 'g_recaptcha' + + website_key = None + website_url = None + + def __init__(self, website_key, website_url): + super(NocaptchaQuestion, self).__init__(self.type, website_key=website_key, website_url=website_url) + + +class RecaptchaQuestion(CaptchaQuestion): + type = 'g_recaptcha' + + website_key = None + website_url = None + + def __init__(self, website_key, website_url): + super(RecaptchaQuestion, self).__init__(self.type, website_key=website_key, website_url=website_url)