修复记住上次选择剧集有时不生效的问题

This commit is contained in:
huangxd- committed 2026-01-07 00:05:47 +08:00
1 parent 7ed66c21c5
commit 545dbdc4af
3 files changed
+16 -6

No files matched your search

+13 -4
View File
@@ -421,8 +421,12 @@ async function matchAniAndEp(season, episode, year, searchData, title, req, plat
// 判断剧集
const normalizedTitle = normalizeSpaces(title);
for (const anime of searchData.animes) {
if (globals.rememberLastSelect && preferAnimeId && anime.bangumiId.toString() !== preferAnimeId.toString() &&
anime.animeId.toString() !== preferAnimeId.toString()) continue;
const animeIsPrefer =
globals.rememberLastSelect &&
preferAnimeId &&
String(anime.bangumiId) !== String(preferAnimeId) &&
String(anime.animeId) !== String(preferAnimeId);
if (animeIsPrefer) continue;
if (normalizeSpaces(anime.animeTitle).includes(normalizedTitle)) {
// 年份匹配优先于季匹配
if (!matchYear(anime, year)) {
@@ -445,7 +449,7 @@ async function matchAniAndEp(season, episode, year, searchData, title, req, plat
log("info", "过滤后的集标题", filteredEpisodes.map(episode => episode.episodeTitle));
// 年份匹配通过后,再判断season
if (matchSeason(anime, title, season)) {
if (matchSeason(anime, title, season) || !animeIsPrefer) {
// 使用新的集数匹配策略
const matchedEpisode = findEpisodeByNumber(filteredEpisodes, episode, platform);
if (matchedEpisode) {
@@ -459,7 +463,12 @@ async function matchAniAndEp(season, episode, year, searchData, title, req, plat
} else {
// 判断电影
for (const anime of searchData.animes) {
if (globals.rememberLastSelect && preferAnimeId && anime.bangumiId.toString() !== preferAnimeId.toString()) continue;
const animeIsPrefer =
globals.rememberLastSelect &&
preferAnimeId &&
String(anime.bangumiId) !== String(preferAnimeId) &&
String(anime.animeId) !== String(preferAnimeId);
if (animeIsPrefer) continue;
const animeTitle = anime.animeTitle.split("(")[0].trim();
if (animeTitle === title) {
// 年份匹配优先
+1 -1
View File
@@ -13,7 +13,7 @@ export const Globals = {
accessedEnvVars: {},
// 静态常量
VERSION: '1.11.0',
VERSION: '1.11.1',
MAX_LOGS: 500, // 日志存储,最多保存 500 行
MAX_ANIMES: 100,
+2 -1
View File
@@ -233,6 +233,7 @@ export function storeAnimeIdsToMap(curAnimes, key) {
// 保存旧的prefer值
const oldValue = globals.lastSelectMap.get(key);
const oldPrefer = oldValue?.prefer;
const oldSource = oldValue?.source;
// 如果key已存在,先删除它(为了更新顺序,保证 FIFO)
if (globals.lastSelectMap.has(key)) {
@@ -242,7 +243,7 @@ export function storeAnimeIdsToMap(curAnimes, key) {
// 添加新记录,保留prefer字段
globals.lastSelectMap.set(key, {
animeIds: [...uniqueAnimeIds],
...(oldPrefer !== undefined && { prefer: oldPrefer })
...(oldPrefer !== undefined && { prefer: oldPrefer, source: oldSource })
});
// 检查是否超过 MAX_LAST_SELECT_MAP,超过则删除最早的