From 50886ac7648bbb71ec395967c9a0a7c2de908791 Mon Sep 17 00:00:00 2001 From: ali Date: Thu, 19 Nov 2026 02:19:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(preflight):=20=E6=8A=A5=E5=91=8A=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E9=9B=86=E4=B8=AD=E7=9B=AE=E5=BD=95=20+=20=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=88=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - [Compatibility] report_dir(默认 /hdd/sda1/Quark-Down/_reports) - 文件名 preflight-YYYYmmdd-HHMMSS.xlsx,同秒冲突自动加序号 - 媒体库根目录不再产生 preflight_report.* --- media/src/core/config.py | 5 +++++ media/src/services/preflight.py | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/media/src/core/config.py b/media/src/core/config.py index ed096bc..1fdc9bc 100644 --- a/media/src/core/config.py +++ b/media/src/core/config.py @@ -88,6 +88,8 @@ write_report = true refresh_jellyfin_after_prep = true # 补轨前的原文件备份目录(相对视频所在目录) backup_dir = .preflight_backup +# 体检报告集中存放目录(每次生成带时间戳 xlsx) +report_dir = /hdd/sda1/Quark-Down/_reports # 电视能直传的音频编码(逗号分隔,按你的电视/客户端实测调整) direct_audio = ac3,eac3,dts,truehd,aac,mp3,mp2,flac,opus,vorbis,pcm_s16le,pcm_s24le,pcm_s32le,pcm_bluray,mlp @@ -195,6 +197,9 @@ DIRECT_AUDIO_CODECS = _csv_set( fallback='ac3,eac3,dts,truehd,aac,mp3,mp2,flac,opus,vorbis,pcm_s16le,pcm_s24le,pcm_s32le,pcm_bluray,mlp') PREFLIGHT_CACHE_PATH = BASE_DIR / 'preflight_cache.json' PREFLIGHT_CACHE_VERSION = 2 +PREFLIGHT_REPORT_DIR = Path( + _parser.get('Compatibility', 'report_dir', fallback='/hdd/sda1/Quark-Down/_reports').strip() + or '/hdd/sda1/Quark-Down/_reports') # 8. 系统与日志路径 _raw_log_path = _parser.get('System', 'log_file_path', fallback='media_manager.log') diff --git a/media/src/services/preflight.py b/media/src/services/preflight.py index cb2d8db..671b716 100644 --- a/media/src/services/preflight.py +++ b/media/src/services/preflight.py @@ -322,6 +322,19 @@ class PreflightService: ])) return rows + @staticmethod + def _report_path(ext: str) -> Path: + """集中目录 + 时间戳:/preflight-YYYYmmdd-HHMMSS.""" + report_dir = config.PREFLIGHT_REPORT_DIR + report_dir.mkdir(parents=True, exist_ok=True) + stamp = time.strftime("%Y%m%d-%H%M%S") + path = report_dir / f"preflight-{stamp}.{ext}" + n = 2 + while path.exists(): + path = report_dir / f"preflight-{stamp}-{n}.{ext}" + n += 1 + return path + @classmethod def write_report(cls, root: Path, results: list, only_issues: bool = False) -> Path | None: """results: [(path, PreflightResult)],输出 root/preflight_report.xlsx(无 openpyxl 时退回 csv)。""" @@ -387,14 +400,14 @@ class PreflightService: for col, width in widths.items(): ws.column_dimensions[col].width = width - report = root / "preflight_report.xlsx" + report = cls._report_path("xlsx") wb.save(report) log.info(f"📄 兼容性报告: {report}") return report @classmethod def _write_csv(cls, root: Path, rows: list) -> Path: - report = root / "preflight_report.csv" + report = cls._report_path("csv") lines = [",".join(cls.HEADERS) + "\n"] for _, _, values in rows: lines.append(",".join('"' + str(v).replace('"', '""') + '"' for v in values) + "\n")