mirror of
https://github.com/shafat-96/anime-mapper
synced 2026-04-17 15:51:45 +00:00
fix
This commit is contained in:
15
src/index.js
15
src/index.js
@@ -222,8 +222,19 @@ app.get('/animepahe/hls/:anilistId/:episode', cache('15 minutes'), async (req, r
|
|||||||
return res.status(404).json({ error: 'No episodes found for this anime on AnimePahe' });
|
return res.status(404).json({ error: 'No episodes found for this anime on AnimePahe' });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the episode with the matching number
|
// Try to find the episode with the exact number first (e.g., AnimePahe episode numbers)
|
||||||
const targetEpisode = mappingResult.animepahe.episodes.find(ep => ep.number === parseInt(episode));
|
let targetEpisode = mappingResult.animepahe.episodes.find(
|
||||||
|
ep => ep.number === parseInt(episode, 10)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!targetEpisode) {
|
||||||
|
const requestedIndex = parseInt(episode, 10) - 1; // convert to 0-based index
|
||||||
|
const episodesArr = mappingResult.animepahe.episodes;
|
||||||
|
|
||||||
|
if (requestedIndex >= 0 && requestedIndex < episodesArr.length) {
|
||||||
|
targetEpisode = episodesArr[requestedIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!targetEpisode) {
|
if (!targetEpisode) {
|
||||||
return res.status(404).json({ error: `Episode ${episode} not found on AnimePahe` });
|
return res.status(404).json({ error: `Episode ${episode} not found on AnimePahe` });
|
||||||
|
|||||||
Reference in New Issue
Block a user