Commit 6aad2796 authored by Florian Duguet's avatar Florian Duguet Committed by Vincent A

weboob.capabilities.captcha: Add HcaptchaQuestion and HcaptchaJob

parent c0ea8d86
......@@ -21,13 +21,14 @@ from time import sleep
from .base import Capability, BaseObject, StringField, UserError, BytesField
from ..exceptions import (
RecaptchaQuestion, RecaptchaV3Question, NocaptchaQuestion, FuncaptchaQuestion, ImageCaptchaQuestion
RecaptchaQuestion, RecaptchaV3Question, NocaptchaQuestion, FuncaptchaQuestion,
ImageCaptchaQuestion, HcaptchaQuestion,
)
__all__ = [
'CapCaptchaSolver',
'SolverJob', 'RecaptchaJob', 'NocaptchaJob', 'ImageCaptchaJob',
'SolverJob', 'RecaptchaJob', 'NocaptchaJob', 'ImageCaptchaJob', 'HcaptchaJob',
'CaptchaError', 'UnsolvableCaptcha', 'InvalidCaptcha', 'InsufficientFunds',
'exception_to_job',
]
......@@ -61,6 +62,11 @@ class FuncaptchaJob(SolverJob):
sub_domain = StringField('Required for some complex cases, but Funcaptcha integrations run without it')
class HcaptchaJob(SolverJob):
site_url = StringField('Site URL for HCaptcha service')
site_key = StringField('Site key for HCaptcha service')
class ImageCaptchaJob(SolverJob):
image = BytesField('data of the image to solve')
......@@ -103,6 +109,10 @@ def exception_to_job(exc):
elif isinstance(exc, ImageCaptchaQuestion):
job = ImageCaptchaJob()
job.image = exc.image_data
elif isinstance(exc, HcaptchaQuestion):
job = HcaptchaJob()
job.site_url = exc.website_url
job.site_key = exc.website_key
else:
raise NotImplementedError()
......
......@@ -171,6 +171,16 @@ class FuncaptchaQuestion(CaptchaQuestion):
self.type, website_key=website_key, website_url=website_url, sub_domain=sub_domain)
class HcaptchaQuestion(CaptchaQuestion):
type = 'hcaptcha'
website_key = None
website_url = None
def __init__(self, website_key, website_url):
super(HcaptchaQuestion, self).__init__(self.type, website_key=website_key, website_url=website_url)
class BrowserHTTPNotFound(Exception):
pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment