diff --git a/src/app/api/openlist/refresh/route.ts b/src/app/api/openlist/refresh/route.ts index bf724b7..632b83d 100644 --- a/src/app/api/openlist/refresh/route.ts +++ b/src/app/api/openlist/refresh/route.ts @@ -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 } // 使用季度的海报(如果有) diff --git a/src/app/play/page.tsx b/src/app/play/page.tsx index 588a510..50a8953 100644 --- a/src/app/play/page.tsx +++ b/src/app/play/page.tsx @@ -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; diff --git a/src/components/CorrectDialog.tsx b/src/components/CorrectDialog.tsx index dca470e..e076670 100644 --- a/src/components/CorrectDialog.tsx +++ b/src/components/CorrectDialog.tsx @@ -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 = { diff --git a/src/lib/season-parser.ts b/src/lib/season-parser.ts index d95af0b..486f66f 100644 --- a/src/lib/season-parser.ts +++ b/src/lib/season-parser.ts @@ -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; } }