Add CaptchaAI as a provider (classic in.php/res.php adapter)
Add CaptchaAI as a provider
Per #366. Adds CaptchaAI as a selectable service.
CaptchaAI is 2Captcha-API-compatible, but via the classic in.php/res.php form-parameter API rather than the JSON createTask API the library uses for the other services. So this PR keeps the public classes unchanged and adds a small adapter that translates the library's task payload into classic params, submits, polls, and returns the usual GetTaskResultResponseSer shape.
Changes
core/enums.py—ServiceEnm.CAPTCHAAI.core/serializer.py—urls_set()routes CaptchaAI tohttps://ocr.captchaai.com/in.php/res.php.core/captchaai.py(new) — classic-API adapter (syncsolve+ asyncaio_solve): maps the createTask payload → classic params, parsesOK|…/CAPCHA_NOT_READY/ERROR_*.core/base.py— routes sync/async processing to the adapter whenservice_type == CAPTCHAAI.README.md— usage note.tests/test_captchaai.py— no-network unit tests.
Usage
from python_rucaptcha.turnstile import Turnstile
from python_rucaptcha.core.enums import ServiceEnm
result = Turnstile(
rucaptcha_key="CAPTCHAAI_KEY",
service_type=ServiceEnm.CAPTCHAAI,
websiteURL="https://example.com",
websiteKey="0x4AAAAAAA...",
userAgent="Mozilla/5.0 ...",
).captcha_handler()
Supported task types
Turnstile, reCAPTCHA v2 (incl. Enterprise), reCAPTCHA v3, ImageToText. Other types raise a clear ValueError so callers fail fast.
Testing
tests/test_captchaai.py(9 unit tests, no network) — enum, URL routing, and all param mappings pass.- Verified live end-to-end: a reCAPTCHA v2 solve through
ServiceEnm.CAPTCHAAIreturns a valid token.
Happy to adjust naming/structure to match your preferences, and to extend the type coverage.
Quick note on the red CI: the failing test (3.11) job is the live suite running without RUCAPTCHA_KEY (GitHub doesn't expose the repo secret to fork PRs), so those failures are the environment, not the change — the tests I added tests/test_captchaai.py) are network-free and pass. Happy to adjust anything when you get a chance to review. Thanks!
Quick note on the red CI: the failing test (3.11) job is the live suite running without RUCAPTCHA_KEY (GitHub doesn't expose the repo secret to fork PRs), so those failures are the environment, not the change — the tests I added tests/test_captchaai.py) are network-free and pass. Happy to adjust anything when you get a chance to review. Thanks!