Skip to content

Commit 1d98d3f

Browse files
authored
fix: 修复跨季集数顺延映射污染偏好记录 (huangxd-#350)
fallbackMatchAniAndEp 通过 isSpillover 标记区分跨季顺延 结果,matchAnime 据此跳过 setLastSearch,避免 spillover 匹配的无关番剧经过 getComment 路径污染 lastSelectMap 偏好。
1 parent 2230a9d commit 1d98d3f

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

danmu_api/apis/dandan-api.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ function findCrossSeasonEpisodeMap(searchData, title, year, season, episode, pla
10491049
// 仅在当前季集三种匹配策略均未命中时才启动相对顺延溢出机制
10501050
if (!season || !episode) return { resEpisode: null, resAnime: null };
10511051

1052-
log("info", `[Spillover] 当前季集匹配策略失败 (S${season}E${episode}),正在进行跨季集数映射匹配...`);
1052+
log("info", `[system] [Spillover] 当前季集匹配策略失败 (S${season}E${episode}),正在进行跨季集数映射匹配...`);
10531053
const normalizedTitle = normalizeSpaces(title);
10541054
const seasonMap = new Map();
10551055

@@ -1114,7 +1114,7 @@ function findCrossSeasonEpisodeMap(searchData, title, year, season, episode, pla
11141114
if (platform && getPlatformMatchScore(extractEpisodeTitle(absoluteMatch.episodeTitle), platform) === 0) {
11151115
break;
11161116
}
1117-
log("info", `[Spillover] 跨季溢出查找命中 (按绝对标题数字) -> 所在季:S${currentSeason} 集标题:${absoluteMatch.episodeTitle}`);
1117+
log("info", `[system] [Spillover] 跨季溢出查找命中 (按绝对标题数字) -> 所在季:S${currentSeason} 集标题:${absoluteMatch.episodeTitle}`);
11181118
bestRes = {
11191119
anime: seasonData.anime,
11201120
episode: absoluteMatch,
@@ -1128,7 +1128,7 @@ function findCrossSeasonEpisodeMap(searchData, title, year, season, episode, pla
11281128
if (platform && getPlatformMatchScore(extractEpisodeTitle(targetEp.episodeTitle), platform) === 0) {
11291129
break;
11301130
}
1131-
log("info", `[Spillover] 跨季溢出查找命中 (按相对排位计算) -> 所在季:S${currentSeason} 集标题:${targetEp.episodeTitle}`);
1131+
log("info", `[system] [Spillover] 跨季溢出查找命中 (按相对排位计算) -> 所在季:S${currentSeason} 集标题:${targetEp.episodeTitle}`);
11321132
bestRes = {
11331133
anime: seasonData.anime,
11341134
episode: targetEp,
@@ -1137,7 +1137,7 @@ function findCrossSeasonEpisodeMap(searchData, title, year, season, episode, pla
11371137
break;
11381138
}
11391139

1140-
log("info", `[Spillover] S${currentSeason} 共有 ${allEps.length} 集(已过滤番外),剩余目标集数为 ${currentTargetEpisode},映射至 S${currentSeason + 1} 继续查找`);
1140+
log("info", `[system] [Spillover] S${currentSeason} 共有 ${allEps.length} 集(已过滤番外),剩余目标集数为 ${currentTargetEpisode},映射至 S${currentSeason + 1} 继续查找`);
11411141
currentTargetEpisode -= allEps.length;
11421142
currentSeason++;
11431143
}
@@ -1377,15 +1377,17 @@ async function fallbackMatchAniAndEp(searchData, req, season, episode, year, tit
13771377
}
13781378

13791379
// 跨季兜底溢出查找逻辑
1380+
let isSpillover = false;
13801381
if (!resEpisode && season && episode) {
13811382
const spilloverRes = findCrossSeasonEpisodeMap(searchData, title, year, season, episode, null, detailStore);
13821383
if (spilloverRes.resEpisode) {
13831384
resEpisode = spilloverRes.resEpisode;
13841385
resAnime = spilloverRes.resAnime;
1386+
isSpillover = true;
13851387
}
13861388
}
13871389

1388-
return {resEpisode, resAnime};
1390+
return {resEpisode, resAnime, isSpillover};
13891391
}
13901392

13911393
export async function extractTitleSeasonEpisode(cleanFileName) {
@@ -1544,6 +1546,7 @@ export async function matchAnime(url, req, clientIp) {
15441546

15451547
let resAnime;
15461548
let resEpisode;
1549+
let spilloverMatched = false;
15471550

15481551
let resData = {
15491552
"errorCode": 0,
@@ -1583,11 +1586,13 @@ export async function matchAnime(url, req, clientIp) {
15831586
const __ret = await fallbackMatchAniAndEp(searchData, req, season, episode, year, title, resEpisode, resAnime, offsets, requestAnimeDetailsMap);
15841587
resEpisode = __ret.resEpisode;
15851588
resAnime = __ret.resAnime;
1589+
// 跨季集数顺延映射的结果不更新 lastSearch,防止无关番剧污染 lastSelectMap 偏好记录
1590+
spilloverMatched = __ret.isSpillover;
15861591
}
15871592
}
15881593

15891594
if (resEpisode) {
1590-
if (clientIp) {
1595+
if (clientIp && !spilloverMatched) {
15911596
setLastSearch(clientIp, { title, season, episode, episodeId: resEpisode.episodeId });
15921597
}
15931598
resData["matches"] = [

0 commit comments

Comments
 (0)