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:
@@ -156,6 +156,7 @@ assets/ # 图标
|
|||||||
| 在 N100 上直接改代码 | 下次 deploy 覆盖 / `-Commit` 会 reset --hard |
|
| 在 N100 上直接改代码 | 下次 deploy 覆盖 / `-Commit` 会 reset --hard |
|
||||||
| `.qkdownloading` | 夸克未下完的临时文件,扫描时跳过 |
|
| `.qkdownloading` | 夸克未下完的临时文件,扫描时跳过 |
|
||||||
| 文件名标签不可信 | 删除/去重前必须 ffprobe 实测(见 `docs/naming.md`) |
|
| 文件名标签不可信 | 删除/去重前必须 ffprobe 实测(见 `docs/naming.md`) |
|
||||||
|
| 改了白名单但旧片名没变 | `media_title` 是缓存派生字段,现读缓存时按当前规则重算;不用手动刷 `tmdb_data.json` |
|
||||||
|
|
||||||
## 10. 媒体库与已知缺口
|
## 10. 媒体库与已知缺口
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
- 年份 = 该季播出年(Season 00 用**每集**播出年)
|
- 年份 = 该季播出年(Season 00 用**每集**播出年)
|
||||||
- 技术标签 = `分辨率.来源.编码.位深.音频`
|
- 技术标签 = `分辨率.来源.编码.位深.音频`
|
||||||
|
|
||||||
|
> `media_title` 是派生字段:读缓存时会按当前白名单从 `tmdb_original_title` 重算,
|
||||||
|
> 缓存里存的历史值不参与命名(否则改了白名单,旧条目名字不会变)。
|
||||||
|
|
||||||
## 二、电影(单版本)
|
## 二、电影(单版本)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -200,6 +200,22 @@ def build_entity(mtype: str, tmdb_id, payload: dict) -> dict:
|
|||||||
return record
|
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]:
|
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)
|
entity = cls._from_search(path, m_type, title, year_s, media_path)
|
||||||
if entity is None:
|
if entity is None:
|
||||||
return None
|
return None
|
||||||
|
# 缓存里的 media_title 可能是旧白名单的产物,先按当前规则重算
|
||||||
|
store.refresh_media_title(entity)
|
||||||
return cls._ensure_season(entity, season_num, year_s)
|
return cls._ensure_season(entity, season_num, year_s)
|
||||||
|
|
||||||
# ------------------------------------------------------------ 三条来源
|
# ------------------------------------------------------------ 三条来源
|
||||||
|
|||||||
Reference in New Issue
Block a user