feat(preflight): 入库前兼容性体检 + 补 AC3 + check 模式
新增 services/preflight.py:ffprobe 判定 READY/PREP/BLOCKED - 视频 hevc/h264、≤2160p、HEVC level 仅提示;DV5 BLOCKED / DV7 人工确认 - 音频直传白名单走 [Compatibility] direct_audio(默认含 mp2) - 默认音轨不可直传时提示;无直传轨时 PREP(add_ac3) - 内嵌 ASS + 大文件且 export 不含 ass 时 PREP(extract_ass) - add_ac3_track 保留全部音轨、首轨转 AC3 5.1 并设默认;prepare_ac3 备份原文件后原子替换 - TaskManager 新增 prepare 阶段(阶段 0),pipeline 在生成计划时先体检 - main.py 新增 check 模式:全库只体检、输出 preflight_report.csv - preflight 结果带版本化缓存(preflight_cache.json),避免重复 ffprobe
This commit is contained in:
@@ -10,6 +10,7 @@ from services.parser import ParserService
|
||||
from services.subtitle import SubtitleService
|
||||
from services.metadata import MetadataService
|
||||
from services.renamer import RenamerService
|
||||
from services.preflight import PreflightService, BLOCKED
|
||||
|
||||
class MediaPipeline:
|
||||
"""中央流水线协调器:接管扫描、判定与防爆防撞逻辑"""
|
||||
@@ -23,6 +24,7 @@ class MediaPipeline:
|
||||
self.media_types_by_root = {}
|
||||
self.tv_episode_tracker = {}
|
||||
self.valid_files = []
|
||||
self.preflight = []
|
||||
|
||||
def run(self):
|
||||
self._analyze_files()
|
||||
@@ -31,6 +33,7 @@ class MediaPipeline:
|
||||
return
|
||||
|
||||
self._generate_plan()
|
||||
PreflightService.write_report(self.target_dir, self.preflight)
|
||||
|
||||
if not self.task_mgr.has_tasks():
|
||||
if not self.auto_execute: log.info("✨ 您的媒体库目前处于完美状态,无需任何物理变更。")
|
||||
@@ -38,7 +41,10 @@ class MediaPipeline:
|
||||
|
||||
if self.task_mgr.preview_and_confirm(self.auto_execute):
|
||||
if not self.auto_execute: log.info("⚙️ 正在执行物理任务...")
|
||||
had_prepare = bool(self.task_mgr.tasks.get('prepare'))
|
||||
self.task_mgr.execute()
|
||||
if had_prepare:
|
||||
PreflightService.refresh_jellyfin()
|
||||
log.info("🎉 流水线操作圆满落地!")
|
||||
elif not self.auto_execute:
|
||||
log.info("💤 任务已由用户取消。")
|
||||
@@ -50,6 +56,10 @@ class MediaPipeline:
|
||||
for f in files_to_process:
|
||||
if f.is_file() and f.suffix.lower() in config.SUPPORTED_EXTS:
|
||||
|
||||
# 跳过隐藏目录(如 .preflight_backup 备份、.git 等)
|
||||
if any(part.startswith('.') for part in f.relative_to(self.target_dir).parts):
|
||||
continue
|
||||
|
||||
# 黑名单拦截
|
||||
if any(excl in str(f) for excl in config.EXCLUDE_DIRS):
|
||||
log.debug(f"🛑 [黑名单拦截] 命中排除规则,跳过扫描: {f.parent.name}/{f.name}")
|
||||
@@ -84,8 +94,29 @@ class MediaPipeline:
|
||||
if m_type == "movie": dir_video_counts[f.parent] += 1
|
||||
|
||||
for f, m_type, title, year, season_num, target_season_folder, root_dir_path, target_root_folder in self.valid_files:
|
||||
# 🧪 入库前体检:能否在电视上直传
|
||||
pf = PreflightService.evaluate(f)
|
||||
self.preflight.append((f, pf))
|
||||
if pf.verdict == BLOCKED:
|
||||
log.error(f"⛔ 无法直传,跳过入库: {f.name} | {'; '.join(pf.reasons)}")
|
||||
continue
|
||||
|
||||
audio_tag = None
|
||||
if 'add_ac3' in pf.actions:
|
||||
if config.AUTO_ADD_AC3:
|
||||
tmp = f.with_name(f".{f.stem}.ac3prep{f.suffix}")
|
||||
self.task_mgr.add_prepare(
|
||||
f"[补 AC3 音轨] {f.name}",
|
||||
PreflightService.prepare_ac3,
|
||||
(f, tmp),
|
||||
)
|
||||
audio_tag = 'AC3.5.1'
|
||||
else:
|
||||
log.warning(f"🟡 [需要补 AC3] {f.name} | auto_add_ac3=false,本次仅提示")
|
||||
|
||||
is_multi = (m_type == "movie" and dir_video_counts.get(f.parent, 0) > 1)
|
||||
target_stem, folder_name = ParserService.get_target_info(f, m_type, title, year, season_num, is_multi)
|
||||
target_stem, folder_name = ParserService.get_target_info(
|
||||
f, m_type, title, year, season_num, is_multi, audio_tag=audio_tag)
|
||||
|
||||
# 集数防撞防爆锁
|
||||
if m_type == "tv":
|
||||
|
||||
Reference in New Issue
Block a user