Add CaptchaAI as a provider (classic in.php/res.php adapter)#367
Open
bshahin wants to merge 2 commits into
Open
Add CaptchaAI as a provider (classic in.php/res.php adapter)#367bshahin wants to merge 2 commits into
bshahin wants to merge 2 commits into
Conversation
CaptchaAI is 2Captcha-API-compatible via the classic in.php/res.php endpoints (rather than the JSON createTask API). Adds ServiceEnm.CAPTCHAAI, URL routing in CaptchaOptionsSer.urls_set(), and a small classic-API adapter (core/captchaai.py) that maps the library's createTask payloads to classic params and parses the classic responses, returning the usual GetTaskResultResponseSer shape so the public Turnstile / ReCaptcha / ImageCaptcha classes work transparently. Supported task types: Turnstile, reCAPTCHA v2 (incl. Enterprise), reCAPTCHA v3, ImageToText; unsupported types raise a clear ValueError. Adds README usage note and tests/test_captchaai.py (no-network unit tests). Refs AndreiDrang#366
|
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! |
1 similar comment
|
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! |
…iohttp + ValueError) Addresses Codacy broad-exception-caught flags on the CaptchaAI adapter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.phpform-parameter API rather than the JSONcreateTaskAPI 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 usualGetTaskResultResponseSershape.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
Supported task types
Turnstile, reCAPTCHA v2 (incl. Enterprise), reCAPTCHA v3, ImageToText. Other types raise a clear
ValueErrorso callers fail fast.Testing
tests/test_captchaai.py(9 unit tests, no network) — enum, URL routing, and all param mappings pass.ServiceEnm.CAPTCHAAIreturns a valid token.Happy to adjust naming/structure to match your preferences, and to extend the type coverage.