Skip to content

Commit

Permalink
无官方中译名时,尝试使用原标题查询
Browse files Browse the repository at this point in the history
  • Loading branch information
Izumiko committed Feb 23, 2024
1 parent 714e590 commit 33db9ac
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion ede.js
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,20 @@
showDebugInfo('查询失败:', error);
return null;
});
if (animaInfo.animes.length == 0) {
const seriesUrl = baseUrl + '/Users/' + userId + '/Items/' + item.SeriesId;
const seriesInfo = await getSessionInfo(seriesUrl, authorization);
animeName = seriesInfo.OriginalTitle;
if (animeName.length > 0) {
searchUrl = apiPrefix + 'https://api.dandanplay.net/api/v2/search/episodes?anime=' + animeName + '&withRelated=true';
animaInfo = await makeGetRequest(searchUrl)
.then((response) => isInTampermonkey ? JSON.parse(response) : response.json())
.catch((error) => {
showDebugInfo('查询失败:', error);
return null;
});
}
}
if (animaInfo.animes.length == 0) {
showDebugInfo('弹幕查询无结果');
return null;
Expand Down Expand Up @@ -922,10 +936,12 @@
const initialep = match ? parseInt(match[1]) : 1;
episode = (parseInt(episode) < initialep) ? parseInt(episode) - 1 : (parseInt(episode) - initialep);
}

const epTitlePrefix = animaInfo.animes[selecAnime_id].type === 'tvseries' ? `S${season}E${episode + 1}` : (animaInfo.animes[selecAnime_id].type);
let episodeInfo = {
episodeId: animaInfo.animes[selecAnime_id].episodes[episode].episodeId,
animeTitle: animaInfo.animes[selecAnime_id].animeTitle,
episodeTitle: animaInfo.animes[selecAnime_id].type === 'tvseries' ? animaInfo.animes[selecAnime_id].episodes[episode].episodeTitle : (animaInfo.animes[selecAnime_id].type === 'movie' ? '剧场版' : 'Other'),
episodeTitle: epTitlePrefix + ' ' + animaInfo.animes[selecAnime_id].episodes[episode].episodeTitle,
};
window.localStorage.setItem(_episode_key, JSON.stringify(episodeInfo));
window.ede.episode_info_str = episodeInfo.animeTitle + '\n' + episodeInfo.episodeTitle;
Expand Down

0 comments on commit 33db9ac

Please sign in to comment.