fix(variety): 期名用「-」后缀并与常规整理互不干扰

- 命名改为 标题.SxxEyy.年份.技术标签-期名,S00 年份取每集播出年
  (与常规整理一致,避免两边各改一次)
- renamer.scan_rename 把「<目标名>-说明」视为已规范,整库扫描不再改回去
- 新增 .variety.json 标识:综艺目录名常常不规范(「花儿与少年」会被
  误匹配到衍生剧「同心季」),常规扫描据此按记录的 tmdb_id 识别
- 剧集根目录年份改用「首播年」而不是某集年份(综艺各集年份不同,
  否则根目录会随扫描顺序乱变)
- 附带把 花儿与少年 已整理的 70 个文件按集号重建为最终格式
This commit is contained in:
ali
2026-11-19 23:03:30 +08:00
parent 5a78cdc79a
commit 3a8e1d1583
4 changed files with 72 additions and 9 deletions
+34 -2
View File
@@ -1,5 +1,6 @@
# src/services/parser.py
import json
import re
from pathlib import Path
from core import config
@@ -74,7 +75,11 @@ class ParserService:
@staticmethod
def _known_tmdb_id(f_path: Path, m_type: str) -> str | None:
"""目录名里已带 [tmdbid-xxx] 时直接返回,避免重复搜索与歧义。"""
"""目录名里已带 [tmdbid-xxx] 时直接返回,避免重复搜索与歧义。
另外检查「综艺整理」留下的 .variety.json 标识:综艺目录名常常不规范
(如「花儿与少年」会误匹配到衍生剧「同心季」),有了标识就按记录的 id 走。
"""
names = [f_path.parent.name]
if m_type == "tv" and f_path.parent.parent is not None:
names.append(f_path.parent.parent.name)
@@ -82,6 +87,27 @@ class ParserService:
match = re.search(r"tmdbid-(\d+)", name, re.I)
if match:
return match.group(1)
marker_id = ParserService._variety_marker_id(f_path)
if marker_id is None:
return None
return str(marker_id)
@staticmethod
def _variety_marker_id(f_path: Path) -> int | None:
"""读取综艺整理留下的 .variety.json(向上最多找 3 层)。"""
folder = f_path.parent
for _ in range(3):
marker = folder / ".variety.json"
if marker.is_file():
try:
data = json.loads(marker.read_text(encoding="utf-8"))
return int(data.get("tmdb_id")) if data.get("tmdb_id") else None
except (OSError, ValueError, TypeError):
return None
if folder.parent == folder:
break
folder = folder.parent
return None
@staticmethod
@@ -166,7 +192,13 @@ class ParserService:
tech = f"{tags['res']}.{source}.{tags['v_codec']}.{tags['bits']}.{tags['a_info']}"
folder_title = title.replace('.', ' ')
target_folder = f"{folder_title} ({fit_year})" if fit_year else folder_title
# 剧集根目录年份用「剧集首播年」:综艺每集年份不同(2022~2025),
# 若用某一集的年份,根目录就会随扫描顺序乱变。
root_year = fit_year
if m_type == "tv":
in_name = re.search(r"(?:19|20)\d{2}", folder_title)
root_year = in_name.group(0) if in_name else str((tmdb or {}).get("year") or "")
target_folder = f"{folder_title} ({root_year})" if root_year else folder_title
if tid:
target_folder = f"{target_folder} {tid}"
target_folder = target_folder.strip()