mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
refactor: inject OCR runtime settings
This commit is contained in:
Vendored
+11
-2
@@ -1,7 +1,8 @@
|
||||
import base64
|
||||
import importlib
|
||||
from typing import Optional
|
||||
|
||||
from app.runtime.config import settings
|
||||
from app.application.configuration import get_runtime_settings
|
||||
from app.adapters.network.http import RequestUtils
|
||||
|
||||
|
||||
@@ -10,7 +11,15 @@ class OcrHelper:
|
||||
OCR 辅助类,负责获取验证码图片并调用 OCR 服务识别文本。
|
||||
"""
|
||||
|
||||
_ocr_b64_url = f"{settings.OCR_HOST}/captcha/base64"
|
||||
def __init__(self, ocr_base_url: Optional[str] = None) -> None:
|
||||
"""初始化 OCR 服务地址,优先使用组合根设置快照。"""
|
||||
if ocr_base_url is None:
|
||||
try:
|
||||
ocr_base_url = get_runtime_settings().get("OCR_HOST")
|
||||
except RuntimeError:
|
||||
legacy_settings = importlib.import_module("app.runtime.config").settings
|
||||
ocr_base_url = legacy_settings.OCR_HOST
|
||||
self._ocr_b64_url = f"{str(ocr_base_url).rstrip('/')}/captcha/base64"
|
||||
|
||||
def get_captcha_text(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user