|
| 1 | +# CORE MODULE |
| 2 | + |
| 3 | +**Generated:** 2026-01-13 |
| 4 | + |
| 5 | +## OVERVIEW |
| 6 | +Core module provides foundational classes for synchronous (`requests`) and asynchronous (`aiohttp`) captcha solving operations. |
| 7 | + |
| 8 | +Base classes establish patterns for Sync/Async instruments, enabling dual concurrency support across the library. Serialization leverages `msgspec` for high-performance JSON handling. |
| 9 | + |
| 10 | +## STRUCTURE |
| 11 | +``` |
| 12 | +src/python3_capsolver/core/ |
| 13 | +├── base.py # CaptchaParams entry class (Sync/Async handlers) |
| 14 | +├── captcha_instrument.py # CaptchaInstrumentBase, FileInstrument |
| 15 | +├── aio_captcha_instrument.py # AIOCaptchaInstrument (async implementation) |
| 16 | +├── sio_captcha_instrument.py # SIOCaptchaInstrument (sync implementation) |
| 17 | +├── serializer.py # Request/Response msgspec Struct classes |
| 18 | +├── enum.py # EndpointPostfixEnm, CaptchaTypeEnm, ResponseStatusEnm |
| 19 | +├── const.py # API URLs, retry configurations |
| 20 | +└── utils.py # Utility functions (attempts_generator) |
| 21 | +``` |
| 22 | + |
| 23 | +## WHERE TO LOOK |
| 24 | +| Task | File | Notes | |
| 25 | +|------|------|-------| |
| 26 | +| **Entry Point** | `base.py` | `CaptchaParams` class with `captcha_handler()` and `aio_captcha_handler()` | |
| 27 | +| **Base Classes** | `captcha_instrument.py` | `CaptchaInstrumentBase` for instruments, `FileInstrument` for file processing | |
| 28 | +| **Sync Instrument** | `sio_captcha_instrument.py` | `SIOCaptchaInstrument` - requests-based implementation | |
| 29 | +| **Async Instrument** | `aio_captcha_instrument.py` | `AIOCaptchaInstrument` - aiohttp-based implementation | |
| 30 | +| **Serialization** | `serializer.py` | `PostRequestSer`, `CaptchaResponseSer`, `MyBaseModel.to_dict()` | |
| 31 | +| **Enums** | `enum.py` | `CaptchaTypeEnm`, `ResponseStatusEnm`, `EndpointPostfixEnm` | |
| 32 | +| **Configuration** | `const.py` | `REQUEST_URL`, `RETRIES`, `VALID_STATUS_CODES` | |
| 33 | + |
| 34 | +## CONVENTIONS |
| 35 | +- **Base Classes**: All instruments inherit from `CaptchaInstrumentBase` |
| 36 | +- **Dual Support**: Every captcha operation provides both sync and async methods |
| 37 | +- **Serialization**: `msgspec.Struct` classes with `to_dict()` method for API payloads |
| 38 | +- **Retries**: `tenacity` for async, `requests.Retry` for sync (5 attempts, exponential backoff) |
| 39 | +- **File Processing**: `FileInstrument` handles local files, URLs, and base64 in both sync/async contexts |
| 40 | +- **Session Management**: Instruments maintain their own HTTP sessions with retry adapters |
0 commit comments