tmdb匹配前先替换下划线为空格,提升匹配概率
This commit is contained in:
@@ -249,7 +249,6 @@ async function performScan(
|
|||||||
// 如果是第二季及以后,替换标题和ID
|
// 如果是第二季及以后,替换标题和ID
|
||||||
if (seasonDetails.season.season_number > 1) {
|
if (seasonDetails.season.season_number > 1) {
|
||||||
folderInfo.title = `${folderInfo.title} ${seasonDetails.season.name}`;
|
folderInfo.title = `${folderInfo.title} ${seasonDetails.season.name}`;
|
||||||
folderInfo.tmdb_id = seasonDetails.season.id; // 使用季度的ID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用季度的海报(如果有)
|
// 使用季度的海报(如果有)
|
||||||
|
|||||||
@@ -2077,7 +2077,7 @@ function PlayPageClient() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let newDetail = availableSources.find(
|
let newDetail: SearchResult | undefined = availableSources.find(
|
||||||
(source) => source.source === newSource && source.id === newId
|
(source) => source.source === newSource && source.id === newId
|
||||||
);
|
);
|
||||||
if (!newDetail) {
|
if (!newDetail) {
|
||||||
@@ -2090,7 +2090,11 @@ function PlayPageClient() {
|
|||||||
try {
|
try {
|
||||||
const detailResponse = await fetch(`/api/detail?source=${newSource}&id=${newId}`);
|
const detailResponse = await fetch(`/api/detail?source=${newSource}&id=${newId}`);
|
||||||
if (detailResponse.ok) {
|
if (detailResponse.ok) {
|
||||||
newDetail = await detailResponse.json();
|
const detailData = await detailResponse.json();
|
||||||
|
if (!detailData) {
|
||||||
|
throw new Error('获取的详情数据为空');
|
||||||
|
}
|
||||||
|
newDetail = detailData;
|
||||||
} else {
|
} else {
|
||||||
throw new Error('获取 openlist 详情失败');
|
throw new Error('获取 openlist 详情失败');
|
||||||
}
|
}
|
||||||
@@ -2102,6 +2106,12 @@ function PlayPageClient() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 再次确认 newDetail 不为空(类型守卫)
|
||||||
|
if (!newDetail) {
|
||||||
|
setError('视频详情数据无效');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 尝试跳转到当前正在播放的集数
|
// 尝试跳转到当前正在播放的集数
|
||||||
let targetIndex = currentEpisodeIndex;
|
let targetIndex = currentEpisodeIndex;
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,6 @@ export default function CorrectDialog({
|
|||||||
|
|
||||||
if (season && season.season_number > 1) {
|
if (season && season.season_number > 1) {
|
||||||
finalTitle = `${finalTitle} ${season.name}`;
|
finalTitle = `${finalTitle} ${season.name}`;
|
||||||
finalTmdbId = season.id; // 使用季度的ID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const body: any = {
|
const body: any = {
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ export interface SeasonInfo {
|
|||||||
*/
|
*/
|
||||||
export function parseSeasonFromTitle(title: string): SeasonInfo {
|
export function parseSeasonFromTitle(title: string): SeasonInfo {
|
||||||
const originalTitle = title;
|
const originalTitle = title;
|
||||||
let cleanTitle = title;
|
// 先将下划线替换成空格,方便后续解析和搜索
|
||||||
|
let cleanTitle = title.replace(/_/g, ' ');
|
||||||
let seasonNumber: number | null = null;
|
let seasonNumber: number | null = null;
|
||||||
let year: number | null = null;
|
let year: number | null = null;
|
||||||
|
|
||||||
@@ -80,13 +81,13 @@ export function parseSeasonFromTitle(title: string): SeasonInfo {
|
|||||||
|
|
||||||
// 尝试匹配每个模式
|
// 尝试匹配每个模式
|
||||||
for (const pattern of patterns) {
|
for (const pattern of patterns) {
|
||||||
const match = title.match(pattern.regex);
|
const match = cleanTitle.match(pattern.regex);
|
||||||
if (match) {
|
if (match) {
|
||||||
const extracted = pattern.extract(match);
|
const extracted = pattern.extract(match);
|
||||||
if (extracted !== null) {
|
if (extracted !== null) {
|
||||||
seasonNumber = extracted;
|
seasonNumber = extracted;
|
||||||
// 移除匹配到的季度标识
|
// 移除匹配到的季度标识
|
||||||
cleanTitle = title.replace(pattern.regex, '').trim();
|
cleanTitle = cleanTitle.replace(pattern.regex, '').trim();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user