fix: reject low-confidence automatic metadata matches

This commit is contained in:
ShukeBta
2026-06-25 02:58:07 +08:00
parent 9021007027
commit 5eb0d4c8af
5 changed files with 138 additions and 8 deletions
+31
View File
@@ -31,6 +31,7 @@ func TestCleanQuery(t *testing.T) {
{"亏成首富从游戏开始 The Richest in Game - S01E11 - 4K.mp4", "亏成首富从游戏开始 the richest in game", 0},
{"紫川.2024.S02E24.第24集.2160p.WEB-DL.H.265-ColorTV.mkv", "紫川", 2024},
{"紫川 (2024) {tmdb-247590}", "紫川", 2024},
{"HNTV.Spring.Festival.Gala.FPS.HLG-QHStudio.S01E202-DD5.QHstudIo.6.4K.ts", "hntv spring festival gala", 0},
}
for _, tc := range cases {
t.Run(tc.in, func(t *testing.T) {
@@ -301,6 +302,36 @@ func TestOrganizeMetadataRejectsEpisodeOnlyQuery(t *testing.T) {
}
}
func TestOrganizeMetadataTrustsExactOriginalTitle(t *testing.T) {
match := &Match{Title: "镖人", OriginalName: "Blades of the Guardians", Year: 2023, TMDbID: 107463}
if !organizeMetadataMatchTrusted("blades of the guardians", 2023, match) {
t.Fatal("exact original title should be trusted")
}
}
func TestOrganizeMetadataTrustsCleanedBroadcastReleaseQuery(t *testing.T) {
match := &Match{Title: "湖南卫视春节联欢晚会", OriginalName: "HNTV Spring Festival Gala", Year: 2026, TMDbID: 123456}
query := "hntv spring festival gala fps hlg qhstudio s01e qhstudio"
if !organizeMetadataMatchTrusted(query, 2026, match) {
t.Fatal("release noise should not block an otherwise matching title")
}
}
func TestOrganizeMetadataRejectsLooseSingleTokenQuery(t *testing.T) {
match := &Match{Title: "步步惊心泰版", OriginalName: "Scarlet Heart Thailand", Year: 2025, TMDbID: 252886}
if organizeMetadataMatchTrusted("thailand", 0, match) {
t.Fatal("single generic token must not trust a broader title")
}
}
func TestOrganizeMetadataRejectsDirtyUnrelatedQuery(t *testing.T) {
match := &Match{Title: "春节联欢晚会", OriginalName: "Spring Festival Gala", Year: 2026, TMDbID: 284725}
query := "hntv spring festival gala fps hlg qhstudio s01e qhstudio"
if organizeMetadataMatchTrusted(query, 2026, match) {
t.Fatal("dirty query with a missing broadcaster token must not trust a partial title")
}
}
func TestSeriesTitleFromMediaPathIgnoresEpisodeOnlyFolder(t *testing.T) {
got := seriesTitleFromMediaPath(`F:\media\电视剧\欧美剧\第 11 集 (2026)\Season 6\第 11 集 - S06E11.mkv`)
if got != "" {