From 46d54bf468560419e1460c95b7249b5ad8a28559 Mon Sep 17 00:00:00 2001 From: alperensert <63921520+alperensert@users.noreply.github.com> Date: Wed, 17 Apr 2024 21:42:01 +0300 Subject: [PATCH 1/2] feat: add TenDI task --- capmonster_python/__init__.py | 1 + capmonster_python/tendi.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 capmonster_python/tendi.py diff --git a/capmonster_python/__init__.py b/capmonster_python/__init__.py index 1c02d13..f209fd1 100644 --- a/capmonster_python/__init__.py +++ b/capmonster_python/__init__.py @@ -9,3 +9,4 @@ from .compleximage import ComplexImageTask from .datadome import DataDomeTask from .turnstile import TurnstileTask +from .tendi import TenDITask diff --git a/capmonster_python/tendi.py b/capmonster_python/tendi.py new file mode 100644 index 0000000..66d79bf --- /dev/null +++ b/capmonster_python/tendi.py @@ -0,0 +1,19 @@ +from .capmonster import UserAgent + +class TenDITask(UserAgent): + def __init__(self, client_key): + super(TenDITask, self).__init__(client_key) + + def create_task(self, website_url: str, website_key: str): + data = { + "clientKey": self._client_key, + "task": { + "type": "CustomTask", + "class": "TenDI", + "websiteURL": website_url, + "websiteKey": website_key + } + } + + data, is_user_agent = self._add_user_agent(data) + return self._make_request("createTask", data).get("taskId") From fa0cd950cf3083d45536edcc81b1fc7697694ce7 Mon Sep 17 00:00:00 2001 From: alperensert <63921520+alperensert@users.noreply.github.com> Date: Wed, 17 Apr 2024 21:50:51 +0300 Subject: [PATCH 2/2] fix: complex image task inaccesible code block fixed Due to a bug in the if statement, the complex image task was not accessible. This has been fixed. --- capmonster_python/compleximage.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/capmonster_python/compleximage.py b/capmonster_python/compleximage.py index ad9f0c3..d25b96e 100644 --- a/capmonster_python/compleximage.py +++ b/capmonster_python/compleximage.py @@ -2,6 +2,8 @@ class ComplexImageTask(UserAgent): + __VALID_CLASSES = ["recaptcha", "hcaptcha"] + def __init__(self, client_key): super(ComplexImageTask, self).__init__(client_key) @@ -11,7 +13,7 @@ def create_task(self, _class: str, grid: str = None, images_base64: list = None, task: str = None, websiteUrl: str = None): - if _class != "recaptcha" or _class != "hcaptcha": + if _class not in self.__VALID_CLASSES: raise ValueError("Currently only recaptcha or hcaptcha is supported as _class value.") data = { "clientKey": self._client_key,