From d32c4327306d1f7785516aa33c6a4b80f5341436 Mon Sep 17 00:00:00 2001 From: Vincent A Date: Sat, 2 Jan 2021 19:08:40 +0100 Subject: [PATCH] core: rename Nocaptcha* to RecaptchaV2* as it's more accurate "No captcha" was the nickname of RecaptchaV2 service, but it's confusing and less precise. Rename and keep compatibility. --- weboob/capabilities/captcha.py | 18 +++++++++++++----- weboob/exceptions.py | 11 +++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/weboob/capabilities/captcha.py b/weboob/capabilities/captcha.py index ecc6f9160c..6db4b1cf28 100644 --- a/weboob/capabilities/captcha.py +++ b/weboob/capabilities/captcha.py @@ -18,17 +18,19 @@ # along with weboob. If not, see . from time import sleep +import warnings from .base import Capability, BaseObject, StringField, UserError, BytesField from ..exceptions import ( - RecaptchaQuestion, RecaptchaV3Question, NocaptchaQuestion, FuncaptchaQuestion, + RecaptchaQuestion, RecaptchaV3Question, RecaptchaV2Question, FuncaptchaQuestion, ImageCaptchaQuestion, HcaptchaQuestion, ) __all__ = [ 'CapCaptchaSolver', - 'SolverJob', 'RecaptchaJob', 'NocaptchaJob', 'ImageCaptchaJob', 'HcaptchaJob', + 'SolverJob', 'RecaptchaJob', 'RecaptchaV2Job', 'RecaptchaV3Job', + 'ImageCaptchaJob', 'HcaptchaJob', 'CaptchaError', 'UnsolvableCaptcha', 'InvalidCaptcha', 'InsufficientFunds', 'exception_to_job', ] @@ -51,11 +53,17 @@ class RecaptchaV3Job(SolverJob): action = StringField('Website owner defines what user is doing on the page through this parameter.') -class NocaptchaJob(SolverJob): +class RecaptchaV2Job(SolverJob): site_url = StringField('Site URL for NoCaptcha service') site_key = StringField('Site key for NoCaptcha service') +class NocaptchaJob(RecaptchaV2Job): + def __init__(self, *args, **kwargs): + warnings.warn('use RecaptchaV2Job class instead', DeprecationWarning) + super(NocaptchaJob, self).__init__(*args, **kwargs) + + class FuncaptchaJob(SolverJob): site_url = StringField('Site URL for FunCaptcha service') site_key = StringField('Site key for FunCaptcha service') @@ -97,8 +105,8 @@ def exception_to_job(exc): job.site_url = exc.website_url job.site_key = exc.website_key job.action = exc.action - elif isinstance(exc, NocaptchaQuestion): - job = NocaptchaJob() + elif isinstance(exc, RecaptchaV2Question): + job = RecaptchaV2Job() job.site_url = exc.website_url job.site_key = exc.website_key elif isinstance(exc, FuncaptchaQuestion): diff --git a/weboob/exceptions.py b/weboob/exceptions.py index 731c87f498..d41c9f22fb 100644 --- a/weboob/exceptions.py +++ b/weboob/exceptions.py @@ -17,6 +17,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with weboob. If not, see . +import warnings from weboob.tools.misc import to_unicode from weboob.tools.compat import StrConv @@ -127,14 +128,20 @@ def __init__(self, image_data): super(ImageCaptchaQuestion, self).__init__(self.type, image_data=image_data) -class NocaptchaQuestion(CaptchaQuestion): +class RecaptchaV2Question(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) + super(RecaptchaV2Question, self).__init__(self.type, website_key=website_key, website_url=website_url) + + +class NocaptchaQuestion(RecaptchaV2Question): + def __init__(self, *args, **kwargs): + warnings.warn('use RecaptchaV2Question class instead', DeprecationWarning) + super(NocaptchaQuestion, self).__init__(*args, **kwargs) class RecaptchaQuestion(CaptchaQuestion): -- GitLab