From 7d6f058001850e52d2fee222238052552da79212 Mon Sep 17 00:00:00 2001 From: morvanzhou Date: Wed, 25 Dec 2024 16:59:47 +0800 Subject: [PATCH] feat(app): update version --- src/retk/core/account/app_captcha.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/retk/core/account/app_captcha.py b/src/retk/core/account/app_captcha.py index 27c2659..f635615 100644 --- a/src/retk/core/account/app_captcha.py +++ b/src/retk/core/account/app_captcha.py @@ -4,17 +4,21 @@ from random import choices from typing import Tuple, Dict, OrderedDict -from captcha.audio import AudioCaptcha -from captcha.image import ImageCaptcha +try: + from captcha.audio import AudioCaptcha + from captcha.image import ImageCaptcha +except ImportError: + img_captcha = None + audio_captcha = None +else: + img_captcha = ImageCaptcha(font_sizes=(35, 30, 32)) + audio_captcha = AudioCaptcha() from retk import const from retk.core.utils import cached_verification DEFAULT_CAPTCHA_EXPIRE_SECOND = 60 -img_captcha = ImageCaptcha(font_sizes=(35, 30, 32)) -audio_captcha = AudioCaptcha() - alphabet = "347ACEFGJLMNPRTY" alphabet_len = len(alphabet) code_idx_range = list(range(0, alphabet_len - 1))