Skip to content

Commit

Permalink
upd docs and typehinting
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiDrang committed Dec 8, 2023
1 parent a53de1e commit eda564e
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 26 deletions.
4 changes: 3 additions & 1 deletion src/python_rucaptcha/amazon_waf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Union

from .core.base import BaseCaptcha
from .core.enums import AmazonWAFCaptchaEnm

Expand All @@ -9,7 +11,7 @@ def __init__(
websiteKey: str,
iv: str,
context: str,
method: str = AmazonWAFCaptchaEnm.AmazonTaskProxyless.value,
method: Union[str, AmazonWAFCaptchaEnm] = AmazonWAFCaptchaEnm.AmazonTaskProxyless,
*args,
**kwargs,
):
Expand Down
2 changes: 1 addition & 1 deletion src/python_rucaptcha/audio_captcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(
Dict with full server response
Notes:
https://rucaptcha.com/api-rucaptcha#audio
https://rucaptcha.com/api-docs/audio
"""

super().__init__(method=AudioCaptchaEnm.AudioTask.value, *args, **kwargs)
Expand Down
13 changes: 10 additions & 3 deletions src/python_rucaptcha/capy_puzzle.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from typing import Union

from .core.base import BaseCaptcha
from .core.enums import CapyPuzzleEnm


class CapyPuzzle(BaseCaptcha):
def __init__(
self, websiteURL: str, websiteKey: str, method: str = CapyPuzzleEnm.CapyTaskProxyless.value, *args, **kwargs
self,
websiteURL: str,
websiteKey: str,
method: Union[str, CapyPuzzleEnm] = CapyPuzzleEnm.CapyTaskProxyless,
*args,
**kwargs,
):
"""
The class is used to work with CapyPuzzle.
Expand Down Expand Up @@ -102,7 +109,7 @@ def __init__(
if method not in CapyPuzzleEnm.list_values():
raise ValueError(f"Invalid method parameter set, available - {CapyPuzzleEnm.list_values()}")

def captcha_handler(self, **kwargs):
def captcha_handler(self, **kwargs) -> dict:
"""
Sync solving method
Expand All @@ -118,7 +125,7 @@ def captcha_handler(self, **kwargs):

return self._processing_response(**kwargs)

async def aio_captcha_handler(self):
async def aio_captcha_handler(self) -> dict:
"""
Async solving method
Expand Down
8 changes: 5 additions & 3 deletions src/python_rucaptcha/fun_captcha.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Union

from .core.base import BaseCaptcha
from .core.enums import FunCaptchaEnm

Expand All @@ -7,7 +9,7 @@ def __init__(
self,
websiteURL: str,
websitePublicKey: str,
method: str = FunCaptchaEnm.FunCaptchaTaskProxyless.value,
method: Union[str, FunCaptchaEnm] = FunCaptchaEnm.FunCaptchaTaskProxyless,
*args,
**kwargs,
):
Expand Down Expand Up @@ -73,7 +75,7 @@ def __init__(
if method not in FunCaptchaEnm.list_values():
raise ValueError(f"Invalid method parameter set, available - {FunCaptchaEnm.list_values()}")

def captcha_handler(self, **kwargs):
def captcha_handler(self, **kwargs) -> dict:
"""
Sync solving method
Expand All @@ -88,7 +90,7 @@ def captcha_handler(self, **kwargs):
"""
return self._processing_response(**kwargs)

async def aio_captcha_handler(self):
async def aio_captcha_handler(self) -> dict:
"""
Async solving method
Expand Down
12 changes: 7 additions & 5 deletions src/python_rucaptcha/hcaptcha.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Union

from .core.base import BaseCaptcha
from .core.enums import HCaptchaEnm

Expand All @@ -7,7 +9,7 @@ def __init__(
self,
websiteURL: str,
websiteKey: str,
method: str = HCaptchaEnm.HCaptchaTaskProxyless.value,
method: Union[str, HCaptchaEnm] = HCaptchaEnm.HCaptchaTaskProxyless,
*args,
**kwargs,
):
Expand All @@ -33,7 +35,7 @@ def __init__(
"solution":{
"token":"P1_eyJ0eXAiOiJKV...1LDq89KyJ5A",
"respKey":"E0_eyJ0eXAiOiJK...y2w5_YbP8PGuJBBo",
"userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.5614.0 Safari/537.36",
"userAgent":"Mozilla/5.0 (.......",
"gRecaptchaResponse":"P1_eyJ0eXAiOiJKV...1LDq89KyJ5A"
},
"cost":"0.00299",
Expand All @@ -55,7 +57,7 @@ def __init__(
"solution":{
"token":"P1_eyJ0eXAiOiJKV...1LDq89KyJ5A",
"respKey":"E0_eyJ0eXAiOiJK...y2w5_YbP8PGuJBBo",
"userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.5614.0 Safari/537.36",
"userAgent":"Mozilla/5.0 (........",
"gRecaptchaResponse":"P1_eyJ0eXAiOiJKV...1LDq89KyJ5A"
},
"cost":"0.00299",
Expand All @@ -80,7 +82,7 @@ def __init__(
if method not in HCaptchaEnm.list_values():
raise ValueError(f"Invalid method parameter set, available - {HCaptchaEnm.list_values()}")

def captcha_handler(self, **kwargs):
def captcha_handler(self, **kwargs) -> dict:
"""
Sync solving method
Expand All @@ -96,7 +98,7 @@ def captcha_handler(self, **kwargs):

return self._processing_response(**kwargs)

async def aio_captcha_handler(self):
async def aio_captcha_handler(self) -> dict:
"""
Async solving method
Expand Down
10 changes: 6 additions & 4 deletions src/python_rucaptcha/key_captcha.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Union

from .core.base import BaseCaptcha
from .core.enums import KeyCaptchaEnm

Expand All @@ -10,7 +12,7 @@ def __init__(
s_s_c_session_id: str,
s_s_c_web_server_sign: str,
s_s_c_web_server_sign2: str,
method: str = KeyCaptchaEnm.KeyCaptchaTaskProxyless.value,
method: Union[str, KeyCaptchaEnm] = KeyCaptchaEnm.KeyCaptchaTaskProxyless,
*args,
**kwargs,
):
Expand Down Expand Up @@ -62,7 +64,7 @@ def __init__(
Dict with full server response
Notes:
https://rucaptcha.com/api-rucaptcha#solving_keycaptcha
https://rucaptcha.com/api-docs/keycaptcha
"""
super().__init__(method=method, *args, **kwargs)

Expand All @@ -80,7 +82,7 @@ def __init__(
if method not in KeyCaptchaEnm.list_values():
raise ValueError(f"Invalid method parameter set, available - {KeyCaptchaEnm.list_values()}")

def captcha_handler(self, **kwargs):
def captcha_handler(self, **kwargs) -> dict:
"""
Sync solving method
Expand All @@ -96,7 +98,7 @@ def captcha_handler(self, **kwargs):

return self._processing_response(**kwargs)

async def aio_captcha_handler(self):
async def aio_captcha_handler(self) -> dict:
"""
Async solving method
Expand Down
8 changes: 5 additions & 3 deletions src/python_rucaptcha/lemin_captcha.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Union

from .core.base import BaseCaptcha
from .core.enums import LeminCaptchaEnm

Expand All @@ -8,7 +10,7 @@ def __init__(
websiteURL: str,
captchaId: str,
div_id: str,
method: str = LeminCaptchaEnm.LeminTaskProxyless.value,
method: Union[str, LeminCaptchaEnm] = LeminCaptchaEnm.LeminTaskProxyless,
*args,
**kwargs,
):
Expand Down Expand Up @@ -82,7 +84,7 @@ def __init__(
if method not in LeminCaptchaEnm.list_values():
raise ValueError(f"Invalid method parameter set, available - {LeminCaptchaEnm.list_values()}")

def captcha_handler(self, **kwargs):
def captcha_handler(self, **kwargs) -> dict:
"""
Sync solving method
Expand All @@ -97,7 +99,7 @@ def captcha_handler(self, **kwargs):
"""
return self._processing_response(**kwargs)

async def aio_captcha_handler(self):
async def aio_captcha_handler(self) -> dict:
"""
Async solving method
Expand Down
10 changes: 7 additions & 3 deletions src/python_rucaptcha/re_captcha.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Union

from .core.base import BaseCaptcha
from .core.enums import ReCaptchaEnm

Expand All @@ -8,7 +10,7 @@ def __init__(
websiteURL: str,
websiteKey: str,
minScore: float = 0.3,
method: str = ReCaptchaEnm.RecaptchaV2TaskProxyless.value,
method: Union[str, ReCaptchaEnm] = ReCaptchaEnm.RecaptchaV2TaskProxyless.value,
*args,
**kwargs,
):
Expand Down Expand Up @@ -127,7 +129,9 @@ def __init__(
Notes:
https://rucaptcha.com/api-docs/recaptcha-v2
https://rucaptcha.com/api-docs/recaptcha-v3
https://rucaptcha.com/api-docs/recaptcha-v2-enterprise
"""
super().__init__(method=method, *args, **kwargs)
Expand All @@ -140,7 +144,7 @@ def __init__(
if method not in ReCaptchaEnm.list_values():
raise ValueError(f"Invalid method parameter set, available - {ReCaptchaEnm.list_values()}")

def captcha_handler(self, **kwargs):
def captcha_handler(self, **kwargs) -> dict:
"""
Sync solving method
Expand All @@ -155,7 +159,7 @@ def captcha_handler(self, **kwargs):
"""
return self._processing_response(**kwargs)

async def aio_captcha_handler(self):
async def aio_captcha_handler(self) -> dict:
"""
Async solving method
Expand Down
8 changes: 5 additions & 3 deletions src/python_rucaptcha/turnstile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Union

from .core.base import BaseCaptcha
from .core.enums import TurnstileCaptchaEnm

Expand All @@ -8,7 +10,7 @@ def __init__(
websiteURL: str,
websiteKey: str,
userAgent: str,
method: str = TurnstileCaptchaEnm.TurnstileTaskProxyless.value,
method: Union[str, TurnstileCaptchaEnm] = TurnstileCaptchaEnm.TurnstileTaskProxyless,
*args,
**kwargs,
):
Expand Down Expand Up @@ -81,7 +83,7 @@ def __init__(
if method not in TurnstileCaptchaEnm.list_values():
raise ValueError(f"Invalid method parameter set, available - {TurnstileCaptchaEnm.list_values()}")

def captcha_handler(self, **kwargs):
def captcha_handler(self, **kwargs) -> dict:
"""
Sync solving method
Expand All @@ -96,7 +98,7 @@ def captcha_handler(self, **kwargs):
"""
return self._processing_response(**kwargs)

async def aio_captcha_handler(self):
async def aio_captcha_handler(self) -> dict:
"""
Async solving method
Expand Down

0 comments on commit eda564e

Please sign in to comment.