forked from 50n50/sources
Update animepahe/animepahe.js
This commit is contained in:
+22
-9
@@ -75,15 +75,28 @@ async function extractEpisodes(url) {
|
||||
const lastPage = data1.last_page;
|
||||
if (lastPage > 1) {
|
||||
for (let p = 2; p <= lastPage; p++) {
|
||||
const apiUrl = `https://animepahe.si/api?m=release&id=${id}&sort=episode_asc&page=${p}`;
|
||||
const response = await ddosInterceptor.fetchWithBypass(apiUrl);
|
||||
const dataText = await response.text();
|
||||
const data = JSON.parse(dataText);
|
||||
for (const item of data.data) {
|
||||
results.push({
|
||||
href: `https://animepahe.si/play/${id}/${item.session}`,
|
||||
number: item.episode
|
||||
});
|
||||
let pageData = null;
|
||||
let retries = 0;
|
||||
while (!pageData && retries < 3) {
|
||||
try {
|
||||
const apiUrl = `https://animepahe.si/api?m=release&id=${id}&sort=episode_asc&page=${p}`;
|
||||
const response = await ddosInterceptor.fetchWithBypass(apiUrl);
|
||||
const dataText = await response.text();
|
||||
pageData = JSON.parse(dataText);
|
||||
} catch (pageErr) {
|
||||
retries++;
|
||||
if (retries < 3) {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pageData) {
|
||||
for (const item of pageData.data) {
|
||||
results.push({
|
||||
href: `https://animepahe.si/play/${id}/${item.session}`,
|
||||
number: item.episode
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user