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

This commit is contained in:
mtvpls
2025-12-26 02:13:53 +08:00
parent d66538e992
commit 0b37e663fe
4 changed files with 16 additions and 7 deletions

View File

@@ -249,7 +249,6 @@ async function performScan(
// 如果是第二季及以后替换标题和ID
if (seasonDetails.season.season_number > 1) {
folderInfo.title = `${folderInfo.title} ${seasonDetails.season.name}`;
folderInfo.tmdb_id = seasonDetails.season.id; // 使用季度的ID
}
// 使用季度的海报(如果有)

View File

@@ -2077,7 +2077,7 @@ function PlayPageClient() {
}
}
let newDetail = availableSources.find(
let newDetail: SearchResult | undefined = availableSources.find(
(source) => source.source === newSource && source.id === newId
);
if (!newDetail) {
@@ -2090,7 +2090,11 @@ function PlayPageClient() {
try {
const detailResponse = await fetch(`/api/detail?source=${newSource}&id=${newId}`);
if (detailResponse.ok) {
newDetail = await detailResponse.json();
const detailData = await detailResponse.json();
if (!detailData) {
throw new Error('获取的详情数据为空');
}
newDetail = detailData;
} else {
throw new Error('获取 openlist 详情失败');
}
@@ -2102,6 +2106,12 @@ function PlayPageClient() {
}
}
// 再次确认 newDetail 不为空(类型守卫)
if (!newDetail) {
setError('视频详情数据无效');
return;
}
// 尝试跳转到当前正在播放的集数
let targetIndex = currentEpisodeIndex;

View File

@@ -178,7 +178,6 @@ export default function CorrectDialog({
if (season && season.season_number > 1) {
finalTitle = `${finalTitle} ${season.name}`;
finalTmdbId = season.id; // 使用季度的ID
}
const body: any = {

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;
}
}