fix(naming): 读缓存时按当前白名单重算 media_title
根因:media_title 是 build_entity 时算好的派生字段,缓存命中不会重算。
78234c5 改了白名单(空格破折号整体视为分隔符),但只刷了本地缓存;
N100 的 tmdb_data.json 被 deploy 排除,仍是旧值,于是重命名计划把
Mission.Impossible.The.Final.Reckoning 改成 ...-.The... 这种更差的名字。
改动:新增 tmdb_store.refresh_media_title(),search_media 返回实体前按
tmdb_original_title + 当前白名单重算,旧缓存不再影响命名。
实测:N100 缓存里 8 条旧记录(碟中谍 4-8、月球叛军两部、马达加斯加企鹅)
重算后均无 ".-.";碟中谍8 单目录计划探针源名 == 目标名、零任务;
全库 find 无 '.-.' 文件名,无需回溯清理。
文档:docs/naming.md 说明派生字段语义,docs/HANDOFF.md 补已知坑。
This commit is contained in:
@@ -200,6 +200,22 @@ def build_entity(mtype: str, tmdb_id, payload: dict) -> dict:
|
||||
return record
|
||||
|
||||
|
||||
def refresh_media_title(entity: dict) -> dict:
|
||||
"""按当前白名单规则重算 media_title,并写回实体。
|
||||
|
||||
media_title 是 build_entity 时算好的派生字段,缓存命中不会重算:
|
||||
sanitize 规则改过之后,旧缓存里仍是历史规则的产物(如
|
||||
「Mission.Impossible.-.The.Final.Reckoning」)。读缓存后统一过一遍,
|
||||
避免「代码改了、文件名没变」。
|
||||
"""
|
||||
localized = entity.get("title") or ""
|
||||
original = entity.get("tmdb_original_title") or ""
|
||||
title = StringUtil.media_title(original, fallback=localized)
|
||||
if title:
|
||||
entity["media_title"] = title
|
||||
return entity
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ 索引
|
||||
|
||||
def lookup(db: dict, mtype: str, title: str, year) -> list[str]:
|
||||
|
||||
@@ -109,6 +109,8 @@ class TMDBService:
|
||||
entity = cls._from_search(path, m_type, title, year_s, media_path)
|
||||
if entity is None:
|
||||
return None
|
||||
# 缓存里的 media_title 可能是旧白名单的产物,先按当前规则重算
|
||||
store.refresh_media_title(entity)
|
||||
return cls._ensure_season(entity, season_num, year_s)
|
||||
|
||||
# ------------------------------------------------------------ 三条来源
|
||||
|
||||
Reference in New Issue
Block a user