mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 07:56:52 +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(
|
||||
|
||||
@@ -5,7 +5,6 @@ author: https://github.com/C5H12O5/syno-videoinfo-plugin
|
||||
import base64
|
||||
import concurrent
|
||||
import concurrent.futures
|
||||
import importlib
|
||||
import json
|
||||
import socket
|
||||
import struct
|
||||
@@ -14,9 +13,9 @@ import urllib.request
|
||||
from threading import Lock
|
||||
from typing import Dict, Optional
|
||||
|
||||
from app.application.configuration import get_runtime_settings
|
||||
from app.runtime.log import logger
|
||||
from app.runtime.reload import ConfigReloadMixin
|
||||
from app.runtime.settings import get_runtime_setting
|
||||
from app.foundation.singleton import Singleton
|
||||
|
||||
# DoH 关闭时需要释放线程池;保持惰性创建可避免未启用 DoH 时占用进程级资源
|
||||
@@ -34,11 +33,7 @@ _orig_getaddrinfo = socket.getaddrinfo
|
||||
|
||||
def _doh_setting(key: str):
|
||||
"""读取 DoH 热更新配置,组合根未装配时兼容旧 Settings。"""
|
||||
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)
|
||||
|
||||
|
||||
def _get_executor_locked() -> concurrent.futures.ThreadPoolExecutor:
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import importlib
|
||||
import logging
|
||||
from functools import lru_cache
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from app.application.configuration import get_runtime_settings
|
||||
from app.runtime.log import logger, log_settings
|
||||
from app.runtime.settings import get_runtime_setting
|
||||
|
||||
try:
|
||||
import moviepilot_rust as _moviepilot_rust
|
||||
@@ -17,11 +16,7 @@ else:
|
||||
|
||||
def _rust_accel_enabled() -> bool:
|
||||
"""读取 Rust 开关快照,组合根未装配时回退旧 Settings。"""
|
||||
try:
|
||||
return bool(get_runtime_settings().get("RUST_ACCEL"))
|
||||
except RuntimeError:
|
||||
legacy_settings = importlib.import_module("app.runtime.config").settings
|
||||
return bool(legacy_settings.RUST_ACCEL)
|
||||
return bool(get_runtime_setting("RUST_ACCEL"))
|
||||
|
||||
|
||||
def is_available() -> bool:
|
||||
|
||||
Reference in New Issue
Block a user