mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
refactor: keep runtime settings below adapters
This commit is contained in:
Vendored
+2
-7
@@ -1,9 +1,8 @@
|
||||
import json
|
||||
import importlib
|
||||
from typing import Any, Dict, Tuple, Optional
|
||||
|
||||
from app.application.configuration import get_runtime_settings
|
||||
from app.runtime.log import logger
|
||||
from app.runtime.settings import get_runtime_setting
|
||||
from app.foundation.crypto import CryptoJsUtils, HashUtils
|
||||
from app.adapters.network.http import RequestUtils
|
||||
from app.domain import site as site_rules
|
||||
@@ -13,11 +12,7 @@ from app.foundation.url import UrlUtils
|
||||
|
||||
def _runtime_setting(key: str) -> Any:
|
||||
"""读取 CookieCloud 配置服务,未装配时回退旧 Settings ABI。"""
|
||||
try:
|
||||
return get_runtime_settings().get(key)
|
||||
except RuntimeError:
|
||||
legacy_settings = importlib.import_module("app.runtime.config").settings
|
||||
return getattr(legacy_settings, key)
|
||||
return get_runtime_setting(key)
|
||||
|
||||
|
||||
class CookieCloudHelper:
|
||||
|
||||
Vendored
+2
-7
@@ -1,9 +1,8 @@
|
||||
import base64
|
||||
import importlib
|
||||
from typing import Optional
|
||||
|
||||
from app.application.configuration import get_runtime_settings
|
||||
from app.adapters.network.http import RequestUtils
|
||||
from app.runtime.settings import get_runtime_setting
|
||||
|
||||
|
||||
class OcrHelper:
|
||||
@@ -14,11 +13,7 @@ class OcrHelper:
|
||||
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
|
||||
ocr_base_url = get_runtime_setting("OCR_HOST")
|
||||
self._ocr_b64_url = f"{str(ocr_base_url).rstrip('/')}/captcha/base64"
|
||||
|
||||
def get_captcha_text(
|
||||
|
||||
Reference in New Issue
Block a user