Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
080b8c4489 | ||
|
|
f30b477a6c | ||
|
|
04a6370b83 | ||
|
|
0a71cac9d0 |
@@ -156,6 +156,7 @@ assets/ # 图标
|
||||
| 在 N100 上直接改代码 | 下次 deploy 覆盖 / `-Commit` 会 reset --hard |
|
||||
| `.qkdownloading` | 夸克未下完的临时文件,扫描时跳过 |
|
||||
| 文件名标签不可信 | 删除/去重前必须 ffprobe 实测(见 `docs/naming.md`) |
|
||||
| 改了白名单但旧片名没变 | `media_title` 是缓存派生字段,现读缓存时按当前规则重算;不用手动刷 `tmdb_data.json` |
|
||||
|
||||
## 10. 媒体库与已知缺口
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
- 年份 = 该季播出年(Season 00 用**每集**播出年)
|
||||
- 技术标签 = `分辨率.来源.编码.位深.音频`
|
||||
|
||||
> `media_title` 是派生字段:读缓存时会按当前白名单从 `tmdb_original_title` 重算,
|
||||
> 缓存里存的历史值不参与命名(否则改了白名单,旧条目名字不会变)。
|
||||
|
||||
## 二、电影(单版本)
|
||||
|
||||
```
|
||||
|
||||
@@ -229,25 +229,27 @@ function Invoke-Worker {
|
||||
continue
|
||||
}
|
||||
|
||||
# 队列已空:只显示一次汇总,然后等按键关闭窗口
|
||||
# 队列已空:只显示一次汇总,然后等 Esc / Enter 关窗
|
||||
if (-not $summaryShown) {
|
||||
Write-Host ('📊 本次共处理 {0} 项:成功 {1},取消 {2},失败 {3}' -f `
|
||||
($done + $cancelled + $failed), $done, $cancelled, $failed) -ForegroundColor Cyan
|
||||
Write-Host ' 按任意键(Esc / Enter)关闭窗口;期间有新任务会接着处理(2 分钟无操作自动关闭)' -ForegroundColor DarkGray
|
||||
Write-Host ' 按 Esc / Enter 关闭窗口;期间有新任务会接着处理(2 分钟无操作自动关闭)' -ForegroundColor DarkGray
|
||||
Write-WorkerLog ("队列处理完毕:成功 {0},取消 {1},失败 {2}" -f $done, $cancelled, $failed)
|
||||
$summaryShown = $true
|
||||
$closeDeadline = (Get-Date).AddSeconds(120)
|
||||
}
|
||||
|
||||
$pressed = $false
|
||||
# 只认 Esc / Enter 关窗:其它键(含误触的字母键)一律忽略,避免窗口被顺手按掉
|
||||
$closeRequested = $false
|
||||
try {
|
||||
if ($Host.UI.RawUI.KeyAvailable) {
|
||||
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
|
||||
$pressed = $true
|
||||
$key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
|
||||
# KeyInfo 没有 ConsoleKey 属性,只能比 VirtualKeyCode(Esc=27 / Enter=13)
|
||||
$closeRequested = $key.VirtualKeyCode -in @([int][ConsoleKey]::Escape, [int][ConsoleKey]::Enter)
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
if ($pressed) { break }
|
||||
if ($closeRequested) { break }
|
||||
if ($null -ne $closeDeadline -and (Get-Date) -ge $closeDeadline) { break }
|
||||
Start-Sleep -Milliseconds 150
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ class MediaPipeline:
|
||||
"""
|
||||
from services.metaclean import MetaCleanService
|
||||
|
||||
files = [f for f in self.valid_files if f.suffix.lower() in config.VIDEO_EXTS]
|
||||
files = [f for f, *_ in self.valid_files if f.suffix.lower() in config.VIDEO_EXTS]
|
||||
if not files:
|
||||
return
|
||||
hits = []
|
||||
|
||||
@@ -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]:
|
||||
|
||||
+12
-2
@@ -18,6 +18,7 @@ class TMDBService:
|
||||
# 本进程内的「负缓存」:同一个目录的每一集都会重复调用 search_media,
|
||||
# 失败结果不记住的话,一个 60 集的剧会白跑 180 次请求。
|
||||
_dead_ids = set() # 详情 404 的 tmdb id
|
||||
_special_years_checked = set() # 本进程内查过 S00 的剧:无特别篇也记住,避免每集重拉
|
||||
_failed_searches = set() # (类型, 归一化标题, 年份) 搜索无结果
|
||||
_id_hits_notified = set() # 目录名 tmdbid 命中:每个 id 只记一次日志
|
||||
_id_entity_cache = {} # 进程内实体缓存,避免每集重读缓存文件
|
||||
@@ -109,6 +110,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)
|
||||
|
||||
# ------------------------------------------------------------ 三条来源
|
||||
@@ -307,7 +310,8 @@ class TMDBService:
|
||||
if season_num in season_years:
|
||||
return entity
|
||||
|
||||
log.info(f"🔄 缓存缺少 S{season_num} 的年份,按需补拉剧集详情...")
|
||||
log.info(f"🔄 缓存缺少《{entity.get('title') or entity['tmdb_id']}》"
|
||||
f"(tv/{entity['tmdb_id']}) S{season_num} 的年份,补拉剧集详情...")
|
||||
session = cls._get_session()
|
||||
payload = cls._fetch_details(session, "tv", entity["tmdb_id"])
|
||||
if payload:
|
||||
@@ -328,7 +332,13 @@ class TMDBService:
|
||||
@classmethod
|
||||
def _load_special_years(cls, entity):
|
||||
"""拉一次 /tv/{id}/season/0,把每个特别篇的播出年份存进实体。"""
|
||||
log.info("🔄 缓存缺少 Season 00 的分集年份,按需补拉特别篇详情...")
|
||||
key = (entity.get("type"), entity.get("tmdb_id"))
|
||||
if key in cls._special_years_checked:
|
||||
return
|
||||
cls._special_years_checked.add(key)
|
||||
|
||||
log.info(f"🔄 缓存缺少《{entity.get('title') or entity['tmdb_id']}》"
|
||||
f"(tv/{entity['tmdb_id']}) 的 S00 特别篇年份,补拉特别篇详情...")
|
||||
session = cls._get_session()
|
||||
payload = cls._fetch_season(session, "tv", entity["tmdb_id"], 0)
|
||||
entity["special_years"] = store.special_years_from(payload) if payload else {}
|
||||
|
||||
Reference in New Issue
Block a user