Skip to content

Commit

Permalink
Merge pull request #241 from AndreiDrang/master
Browse files Browse the repository at this point in the history
Release v6.2
  • Loading branch information
AndreiDrang authored Apr 29, 2024
2 parents a5717fc + 8c69345 commit 81f9b03
Show file tree
Hide file tree
Showing 18 changed files with 431 additions and 158 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand All @@ -30,6 +30,4 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Local build checking
run: |
pip install twine wheel
cd src/ && python setup.py sdist bdist_wheel
run: make build
2 changes: 1 addition & 1 deletion .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]
python-version: ["3.12"]

steps:
- uses: actions/checkout@v4
Expand Down
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
install:
cd src/ && pip3 install -e .
pip3 install -e .

remove:
pip3 uninstall python_rucaptcha -y
Expand All @@ -23,13 +23,17 @@ lint:
black src/ --check && \
isort src/ --check-only

build:
pip3 install --upgrade build setuptools
python3 -m build

upload:
pip3 install twine wheel
cd src/ && python setup.py upload
pip3 install twine wheel setuptools build
twine upload dist/*

tests: install
coverage run --rcfile=.coveragerc -m pytest --verbose --showlocals --pastebin=all \
tests/ --disable-warnings && \
tests/test_tencent.py --disable-warnings && \
coverage report --precision=3 --sort=cover --skip-empty --show-missing && \
coverage html --precision=3 --skip-empty -d coverage/html/ && \
coverage xml -o coverage/coverage.xml
Expand Down
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
from python_rucaptcha import (
core,
control,
tencent,
gee_test,
hcaptcha,
turnstile,
amazon_waf,
mt_captcha,
re_captcha,
atb_captcha,
capy_puzzle,
fun_captcha,
key_captcha,
Expand Down
12 changes: 12 additions & 0 deletions docs/modules/atb-captcha/example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
atbCaptcha
==========

To import this module:

.. code-block:: python
from python_rucaptcha.atb_captcha import atbCaptcha
.. autoclass:: python_rucaptcha.atb_captcha.atbCaptcha
:members:
6 changes: 6 additions & 0 deletions docs/modules/enum/info.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,9 @@ To import this module:

.. autoenum:: python_rucaptcha.core.enums.FriendlyCaptchaEnm
:members:

.. autoenum:: python_rucaptcha.core.enums.TencentEnm
:members:

.. autoenum:: python_rucaptcha.core.enums.atbCaptchaEnm
:members:
12 changes: 12 additions & 0 deletions docs/modules/tencent/example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Tencent
=======

To import this module:

.. code-block:: python
from python_rucaptcha.tencent import Tencent
.. autoclass:: python_rucaptcha.tencent.Tencent
:members:
79 changes: 79 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,82 @@ testpaths = [
"tests",
]
addopts = "-vv --tb=short --durations=10"

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "python-rucaptcha"
dynamic = ["version"]
authors = [
{name = "AndreiDrang", email = "[email protected]"},
]
description = "Python 3.9+ RuCaptcha library with AIO module."
readme = "README.md"
requires-python = ">=3.9"
keywords = [ "captcha",
"rucaptcha",
"2captcha",
"deathbycaptcha",
"recaptcha",
"geetest",
"hcaptcha",
"capypuzzle",
"tiktok",
"rotatecaptcha",
"funcaptcha",
"keycaptcha",
"python3",
"recaptcha",
"captcha",
"security",
"tiktok",
"tencent",
"atb_captcha",
"python-library",
"python-rucaptcha",
"rucaptcha-client",
"yandex",
"turnstile",
"amazon",
"amazon_waf",
"friendly-captcha"
]
license = {text = "MIT License"}
classifiers = [
"License :: OSI Approved :: MIT License",
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Framework :: AsyncIO",
"Operating System :: Unix",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS",
]
dependencies = [
"requests>=2.21.0",
"aiohttp>=3.9.2",
"msgspec==0.18.*",
"tenacity==8.*"
]

[tool.setuptools.packages.find]
where = ["src"]
include = ["python_rucaptcha*"]

[tool.setuptools.dynamic]
version = {attr = "python_rucaptcha.__version__"}

[project.urls]
Homepage = "https://andreidrang.github.io/python-rucaptcha/"
Documentation = "https://andreidrang.github.io/python-rucaptcha/"
Repository = "https://github.com/AndreiDrang/python-rucaptcha"
Issues = "https://github.com/AndreiDrang/python-rucaptcha/issues"
Changelog = "https://github.com/AndreiDrang/python-rucaptcha/releases"
1 change: 1 addition & 0 deletions src/python_rucaptcha/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from python_rucaptcha.__version__ import __version__ # noqa
2 changes: 1 addition & 1 deletion src/python_rucaptcha/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "6.1.2"
__version__ = "6.2"
110 changes: 110 additions & 0 deletions src/python_rucaptcha/atb_captcha.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
from typing import Union

from .core.base import BaseCaptcha
from .core.enums import atbCaptchaEnm


class atbCaptcha(BaseCaptcha):
def __init__(
self,
websiteURL: str,
appId: str,
apiServer: str,
method: Union[str, atbCaptchaEnm] = atbCaptchaEnm.AtbCaptchaTaskProxyless,
*args,
**kwargs,
):
"""
The class is used to work with CapyPuzzle.
Args:
rucaptcha_key: User API key
websiteURL: The full URL of target web page where the captcha is loaded.
We do not open the page, not a problem if it is available only for authenticated users
appId: The value of `appId` parameter in the website source code.
apiServer: The value of `apiServer` parameter in the website source code.
method: Captcha type
Examples:
>>> atbCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122",
... websiteURL="https://www.tencentcloud.com/account/register",
... appId="2009899766",
... apiServer="https://cap.aisecurius.com",
... method=atbCaptchaEnm.AtbCaptchaTaskProxyless.value,
... ).captcha_handler()
{
"errorId":0,
"status":"ready",
"solution":{
"token": "sl191suxzluwxxh6f:"
},
"cost":"0.00299",
"ip":"1.2.3.4",
"createTime":1692863536,
"endTime":1692863556,
"solveCount":1,
"taskId":75190409731
}
>>> await atbCaptcha(rucaptcha_key="aa9011f31111181111168611f1151122",
... websiteURL="https://www.tencentcloud.com/account/register",
... appId="2009899766",
... apiServer="https://cap.aisecurius.com",
... method=atbCaptchaEnm.AtbCaptchaTaskProxyless.value,
... ).aio_captcha_handler()
{
"errorId":0,
"status":"ready",
"solution":{
"token": "sl191suxzluwxxh6f:"
},
"cost":"0.00299",
"ip":"1.2.3.4",
"createTime":1692863536,
"endTime":1692863556,
"solveCount":1,
"taskId":75190409731
}
Returns:
Dict with full server response
Notes:
https://rucaptcha.com/api-docs/atb-captcha
https://2captcha.com/api-docs/atb-captcha
"""
super().__init__(method=method, *args, **kwargs)

self.create_task_payload["task"].update({"websiteURL": websiteURL, "appId": appId, "apiServer": apiServer})

# check user params
if method not in atbCaptchaEnm.list_values():
raise ValueError(f"Invalid method parameter set, available - {atbCaptchaEnm.list_values()}")

def captcha_handler(self, **kwargs) -> dict:
"""
Sync solving method
Args:
kwargs: additional params for `requests` library
Returns:
Dict with full server response
Notes:
Check class docstirng for more info
"""

return self._processing_response(**kwargs)

async def aio_captcha_handler(self) -> dict:
"""
Async solving method
Returns:
Dict with full server response
Notes:
Check class docstirng for more info
"""
return await self._aio_processing_response()
3 changes: 3 additions & 0 deletions src/python_rucaptcha/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def __init__(
https://rucaptcha.com/api-docs/get-balance
https://rucaptcha.com/api-docs/report-correct
https://rucaptcha.com/api-docs/report-incorrect
https://2captcha.com/api-docs/get-balance
https://2captcha.com/api-docs/report-correct
https://2captcha.com/api-docs/report-incorrect
"""

super().__init__(method=ControlEnm.control, *args, **kwargs)
Expand Down
10 changes: 10 additions & 0 deletions src/python_rucaptcha/core/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,13 @@ class GridCaptchaEnm(str, MyEnum):
class FriendlyCaptchaEnm(str, MyEnum):
FriendlyCaptchaTaskProxyless = "FriendlyCaptchaTaskProxyless"
FriendlyCaptchaTask = "FriendlyCaptchaTask"


class TencentEnm(str, MyEnum):
TencentTask = "TencentTask"
TencentTaskProxyless = "TencentTaskProxyless"


class atbCaptchaEnm(str, MyEnum):
AtbCaptchaTask = "AtbCaptchaTask"
AtbCaptchaTaskProxyless = "AtbCaptchaTaskProxyless"
Loading

0 comments on commit 81f9b03

Please sign in to comment.