From d0e5163869c4a718606f9afaef0b10d2c3cb1f4d Mon Sep 17 00:00:00 2001 From: Andrei Date: Fri, 8 Dec 2023 00:47:59 +0300 Subject: [PATCH] Update image_captcha.py --- src/python_rucaptcha/image_captcha.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/python_rucaptcha/image_captcha.py b/src/python_rucaptcha/image_captcha.py index 81be8d68..7f78bb92 100644 --- a/src/python_rucaptcha/image_captcha.py +++ b/src/python_rucaptcha/image_captcha.py @@ -1,5 +1,5 @@ import shutil -from typing import Optional +from typing import Union, Optional from .core.base import BaseCaptcha from .core.enums import SaveFormatsEnm, ImageCaptchaEnm @@ -8,7 +8,7 @@ class ImageCaptcha(BaseCaptcha): def __init__( self, - save_format: str = SaveFormatsEnm.TEMP.value, + save_format: Union[str, SaveFormatsEnm] = SaveFormatsEnm.TEMP, img_clearing: bool = True, img_path: str = "PythonRuCaptchaImages", *args, @@ -199,7 +199,12 @@ def captcha_handler( Check class docstirng for more info """ self._body_file_processing( - captcha_link=captcha_link, captcha_file=captcha_file, captcha_base64=captcha_base64, **kwargs + save_format=self.save_format, + file_path=self.img_path, + captcha_link=captcha_link, + captcha_file=captcha_file, + captcha_base64=captcha_base64, + **kwargs, ) if not self.result.errorId: return self._processing_response(**kwargs) @@ -228,7 +233,12 @@ async def aio_captcha_handler( Check class docstirng for more info """ await self._aio_body_file_processing( - captcha_link=captcha_link, captcha_file=captcha_file, captcha_base64=captcha_base64, **kwargs + save_format=self.save_format, + file_path=self.img_path, + captcha_link=captcha_link, + captcha_file=captcha_file, + captcha_base64=captcha_base64, + **kwargs, ) if not self.result.errorId: return await self._aio_processing_response()