refactor(config): 设备能力/外部服务/阈值等硬编码收敛到 config.ini(P0+P1)
This commit is contained in:
@@ -29,7 +29,9 @@ from pathlib import Path
|
||||
|
||||
from core import config
|
||||
from core.logger import log
|
||||
from services.metaclean import AD_PATTERN
|
||||
|
||||
# 广告特征由 config.ini [Ads] keywords + patterns 合成(见 core/config.py)
|
||||
AD_PATTERN = config.AD_PATTERN
|
||||
|
||||
# 参与扫描的字段:Jellyfin 界面里会显示成备注/类型/工作室/标签的那几个
|
||||
_SCAN_FIELDS = "Path,Overview,Genres,Studios,Tags,Tagline,SeriesId"
|
||||
@@ -67,7 +69,8 @@ class JellyfinClient:
|
||||
|
||||
# ---------------------------------------------------------------- HTTP
|
||||
|
||||
def _request(self, path: str, method: str = "GET", payload=None, params=None, retries: int = 3):
|
||||
def _request(self, path: str, method: str = "GET", payload=None, params=None, retries: int | None = None):
|
||||
retries = retries or config.JELLYFIN_RETRIES
|
||||
params = dict(params or {})
|
||||
params.setdefault("api_key", self.key)
|
||||
url = f"{self.base}{path}?" + urllib.parse.urlencode(params)
|
||||
@@ -79,7 +82,7 @@ class JellyfinClient:
|
||||
for attempt in range(1, retries + 1):
|
||||
try:
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60) as resp:
|
||||
with urllib.request.urlopen(req, timeout=config.JELLYFIN_TIMEOUT) as resp:
|
||||
body = resp.read()
|
||||
return json.loads(body) if body else None
|
||||
except urllib.error.HTTPError as exc:
|
||||
@@ -359,6 +362,7 @@ class JellyfinAdFixService:
|
||||
|
||||
@classmethod
|
||||
def write_report(cls, stats: dict) -> Path:
|
||||
path = config.BASE_DIR.parent.parent / "adfix-report.json"
|
||||
path = config.JELLYFIN_REPORT_PATH
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(json.dumps(stats, ensure_ascii=False, indent=1), encoding="utf-8")
|
||||
return path
|
||||
|
||||
Reference in New Issue
Block a user