tmdb匹配前先替换下划线为空格,提升匹配概率

This commit is contained in:
mtvpls
2025-12-26 02:20:19 +08:00
parent d66538e992
commit 0b37e663fe
4 changed files with 16 additions and 7 deletions
+4 -3
View File
@@ -27,7 +27,8 @@ export interface SeasonInfo {
*/
export function parseSeasonFromTitle(title: string): SeasonInfo {
const originalTitle = title;
let cleanTitle = title;
// 先将下划线替换成空格,方便后续解析和搜索
let cleanTitle = title.replace(/_/g, ' ');
let seasonNumber: number | null = null;
let year: number | null = null;
@@ -80,13 +81,13 @@ export function parseSeasonFromTitle(title: string): SeasonInfo {
// 尝试匹配每个模式
for (const pattern of patterns) {
const match = title.match(pattern.regex);
const match = cleanTitle.match(pattern.regex);
if (match) {
const extracted = pattern.extract(match);
if (extracted !== null) {
seasonNumber = extracted;
// 移除匹配到的季度标识
cleanTitle = title.replace(pattern.regex, '').trim();
cleanTitle = cleanTitle.replace(pattern.regex, '').trim();
break;
}
}