Skip to content

Commit 22ba26a

Browse files
authored
fix: 修复源不在优选平台时跨季被跳过,并使弹弹关联作品可参与跨季匹配 (huangxd-#412)
handleAnimes发现关联作品后追加到sourceAnimes参数,不受canExpandRelateds 约束。同ID唯一性检查确保注入行为与搜索结果一致,不产生重复getEpisodes请求。 existingIds记录始终执行以消除并发竞态窗口。 跨季源过滤新增unsatisfiedPlatforms.size>0条件:当targetPlatform设了 但unsatisfiedPlatforms为空时不再跳过所有源。
1 parent d0ce3b9 commit 22ba26a

2 files changed

Lines changed: 23 additions & 10 deletions

File tree

danmu_api/apis/dandan-api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,8 @@ export async function searchAnime(url, preferAnimeId = null, preferSource = null
838838
const expandPromises = [];
839839
for (const source of globals.sourceOrderArr) {
840840
if (!resultData[source]) continue;
841-
// 在PLATFORM_ORDER模式下,跳过已满足平台的对应源
842-
if (targetPlatform && !unsatisfiedPlatforms.has(source)) continue;
841+
// 在PLATFORM_ORDER模式下,跳过已满足平台的对应源;unsatisfied为空时不跳过
842+
if (targetPlatform && unsatisfiedPlatforms.size > 0 && !unsatisfiedPlatforms.has(source)) continue;
843843
// 源间并发、源内顺序,防止同源并发导致模块级缓存竞态
844844
expandPromises.push((async () => {
845845
const sourceResults = [];

danmu_api/sources/dandan.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -367,18 +367,31 @@ export default class DandanSource extends BaseSource {
367367

368368
// 相似度高于10%时,对每个关联作品单独判断是否符合展开条件:
369369
// 关联作品标题含季度信息(避免范围发散),或初始搜索结果不少于25个(API25个结果上限,用相关作品突破)
370-
if (similarity >= 0.1 && details.relateds && Array.isArray(details.relateds) && canExpandRelateds) {
370+
if (similarity >= 0.1 && details.relateds && Array.isArray(details.relateds)) {
371371
for (const rel of details.relateds) {
372372
const hasSeason = extractSeasonNumberFromAnimeTitle(rel.animeTitle).season !== null;
373373
if (!existingIds.has(rel.animeId) && (hasSeason || initialCount >= 25)) {
374374
existingIds.add(rel.animeId);
375-
queue.push({
376-
animeId: rel.animeId,
377-
animeTitle: rel.animeTitle,
378-
imageUrl: rel.imageUrl,
379-
rating: rel.rating || 0,
380-
isRelated: true // 标记动态挖掘出的条目为相关作品
381-
});
375+
// 关联作品追加到sourceAnimes供跨季扩展感知
376+
if (!sourceAnimes.some(a => a.animeId === rel.animeId)) {
377+
sourceAnimes.push({
378+
animeId: rel.animeId,
379+
animeTitle: rel.animeTitle,
380+
title: rel.animeTitle,
381+
imageUrl: rel.imageUrl,
382+
rating: rel.rating || 0,
383+
isRelated: true
384+
});
385+
}
386+
if (canExpandRelateds) {
387+
queue.push({
388+
animeId: rel.animeId,
389+
animeTitle: rel.animeTitle,
390+
imageUrl: rel.imageUrl,
391+
rating: rel.rating || 0,
392+
isRelated: true // 标记动态挖掘出的条目为相关作品
393+
});
394+
}
382395
}
383396
}
384397
}

0 commit comments

Comments
 (0)