You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: add Yandex SmartCaptcha Kaleidoscope support - #26
@dariyaanis Thanks for the PR! The new task type is well put together - tests, sync/async examples and docs are all there, and pytest, ruff and mypy pass locally. A few things to address before merging:
Required
1. solve() return type changed to Any - captcha_solver_api/client.py:248, captcha_solver_api/async_client.py:265
Changing the return type from Dict[str, Any] to Any removes type checking of the solve() result for every user, not just Kaleidoscope ones. Suggest Union[Dict[str, Any], str] instead - it keeps the types honest and makes it explicit that the result needs narrowing. Open to other ideas if you have a better option.
2. Empty string is accepted as a valid solution - captcha_solver_api/client.py:313, captcha_solver_api/async_client.py:335
If the API returns "solution": "", the isinstance(solution, (dict, str)) check lets it through and solve() returns "" as a successful result. Please treat an empty string as an invalid response and raise NetworkError, same as for other malformed solutions, and add a test for this case.
Optional (nit)
3. task accepts only a JSON string - captcha_solver_api/tasks.py:957
Users will likely pass a plain list ([15, 24, 4]), which would be sent to the API as an array instead of a string. Consider accepting Union[str, List[int]] and serializing lists with json.dumps, or raising ValidationError for non-string values.
Note
This PR conflicts with #27 (debug mode) in client.py and async_client.py. I suggest merging this one first and then rebasing #27 on top of it.
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
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.
Summary
YandexSmartCaptchaKaleidoscopeTaskfor the API v2PazlCaptchaTasktypeAPI
The task is serialized as:
{ "type": "PazlCaptchaTask", "image": "BASE64_IMAGE", "task": "[15,24,4,13,10]" }The API returns a string such as
"8", representing the number of slider-arrow clicks required to solve the puzzle.Examples
python examples/sync/yandex_smartcaptcha_kaleidoscope.pypython examples/async/yandex_smartcaptcha_kaleidoscope.pyBoth examples use
examples/assets/yandex-smartcaptcha-kaleidoscope.jpgand the full puzzle-step sequence from the working request.Testing
python -m pytest -q -p no:cacheprovider— 127 passedpython -m ruff check .— passedpython -m compileall -q captcha_solver_api examples tests— passedpython -m build— wheel and source distribution built successfully