1717 ((RecaptchaV2Request ,), getRecaptchaV2Timeouts ),
1818 ((RecaptchaV2EnterpriseRequest ,), getRecaptchaV2EnterpriseTimeouts ),
1919 ((RecaptchaV3ProxylessRequest ), getRecaptchaV3Timeouts ),
20+ ((RecaptchaV3EnterpriseRequest ), getRecaptchaV3Timeouts ),
2021 ((ImageToTextRequest ), getImage2TextTimeouts ),
2122 ((FuncaptchaRequest ,), getFuncaptchaTimeouts ),
2223 ((HcaptchaRequest ,), getHcaptchaTimeouts ),
3536 ((YidunRequest ), getYidunTimeouts ),
3637 ((TemuCustomTaskRequest ), getTemuTimeouts ),
3738 ((ProsopoTaskRequest ), getProsopoTimeouts ),
39+ ((AltchaCustomTaskRequest ), getAltchaTimeouts ),
3840)
3941
4042
@@ -44,6 +46,14 @@ def __init__(self,
4446 self .options = options
4547 self ._headers = {'User-Agent' :
4648 f'Zennolab.CapMonsterCloud.Client.Python/{ parseVersion ()} ' }
49+ if self .options .client_proxy :
50+ if self .options .client_proxy .proxyType not in ['http' , 'https' ]:
51+ raise UnsupportedProxyTypeError (f'Supported client proxy types are: [HTTP, HTTPS]' )
52+ if self .options .client_proxy .proxyLogin and self .options .client_proxy .proxyPassword :
53+ auth = f"{ self .options .client_proxy .proxyLogin } :{ self .options .client_proxy .proxyPassword } @"
54+ self .client_proxy_string = f"{ self .options .client_proxy .proxyType } ://{ auth } { self .options .client_proxy .proxyAddress } :{ self .options .client_proxy .proxyPort } "
55+ else :
56+ self .client_proxy_string = None
4757
4858 @property
4959 def headers (self ):
@@ -56,7 +66,8 @@ async def get_balance(self) -> Dict[str, Union[int, float, str]]:
5666 async with aiohttp .ClientSession () as session :
5767 async with session .post (url = self .options .service_url + '/getBalance' ,
5868 json = body ,
59- timeout = aiohttp .ClientTimeout (total = self .options .client_timeout )) as resp :
69+ timeout = aiohttp .ClientTimeout (total = self .options .client_timeout ),
70+ proxy = self .client_proxy_string ) as resp :
6071 if resp .status != 200 :
6172 raise HTTPException (f'Cannot create task. Status code: { resp .status } .' )
6273 result = await resp .json (content_type = None )
@@ -69,6 +80,7 @@ async def solve_captcha(self, request: Union[
6980 RecaptchaV2EnterpriseRequest ,
7081 RecaptchaV2Request ,
7182 RecaptchaV3ProxylessRequest ,
83+ RecaptchaV3EnterpriseRequest ,
7284 RecaptchaComplexImageTaskRequest ,
7385 ImageToTextRequest ,
7486 FuncaptchaRequest ,
@@ -87,7 +99,8 @@ async def solve_captcha(self, request: Union[
8799 MTCaptchaRequest ,
88100 YidunRequest ,
89101 TemuCustomTaskRequest ,
90- ProsopoTaskRequest ],
102+ ProsopoTaskRequest ,
103+ AltchaCustomTaskRequest ],
91104 ) -> Dict [str , str ]:
92105 '''
93106 Non-blocking method for captcha solving.
@@ -106,6 +119,7 @@ async def _solve(self, request: Union[
106119 RecaptchaV2EnterpriseRequest ,
107120 RecaptchaV2Request ,
108121 RecaptchaV3ProxylessRequest ,
122+ RecaptchaV3EnterpriseRequest ,
109123 RecaptchaComplexImageTaskRequest ,
110124 ImageToTextRequest ,
111125 FuncaptchaRequest ,
@@ -124,7 +138,8 @@ async def _solve(self, request: Union[
124138 MTCaptchaRequest ,
125139 YidunRequest ,
126140 TemuCustomTaskRequest ,
127- ProsopoTaskRequest ],
141+ ProsopoTaskRequest ,
142+ AltchaCustomTaskRequest ],
128143 timeouts : GetResultTimeouts ,
129144 ) -> Dict [str , str ]:
130145
@@ -168,7 +183,8 @@ async def _getTaskResult(self, task_id: str) -> Dict[str, Union[int, str, None]]
168183 async with session .post (url = self .options .service_url + '/getTaskResult' ,
169184 json = body ,
170185 timeout = aiohttp .ClientTimeout (total = self .options .client_timeout ),
171- headers = self .headers ) as resp :
186+ headers = self .headers ,
187+ proxy = self .client_proxy_string ) as resp :
172188 if resp .status != 200 :
173189 if resp .status == 500 :
174190 return {'errorId' : 0 , 'status' : 'processing' }
@@ -184,11 +200,13 @@ async def _createTask(self, request: BaseRequest) -> Dict[str, Union[str, int]]:
184200 "task" : task ,
185201 "softId" : self .options .default_soft_id
186202 }
203+
187204 async with aiohttp .ClientSession () as session :
188205 async with session .post (url = self .options .service_url + '/createTask' ,
189206 json = body ,
190207 timeout = aiohttp .ClientTimeout (total = self .options .client_timeout ),
191- headers = self .headers ) as resp :
208+ headers = self .headers ,
209+ proxy = self .client_proxy_string ) as resp :
192210 if resp .status != 200 :
193211 raise HTTPException (f'Cannot create task. Status code: { resp .status } .' )
194212 else :
0 commit comments