mirror of
https://git.luna-app.eu/50n50/sources
synced 2026-01-12 01:18:11 +01:00
Update animepahe/animepahe.js
This commit is contained in:
parent
8d10fefb7e
commit
b9eb0166cc
1 changed files with 23 additions and 12 deletions
|
|
@ -74,20 +74,31 @@ async function extractEpisodes(url) {
|
|||
|
||||
const lastPage = data1.last_page;
|
||||
if (lastPage > 1) {
|
||||
const pagePromises = [];
|
||||
for (let p = 2; p <= lastPage; p++) {
|
||||
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++;
|
||||
pagePromises.push((async (pageNum) => {
|
||||
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=${pageNum}`;
|
||||
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, 500));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pageData) {
|
||||
return pageData;
|
||||
})(p));
|
||||
}
|
||||
|
||||
const allPagesData = await Promise.all(pagePromises);
|
||||
for (const pageData of allPagesData) {
|
||||
if (pageData && pageData.data) {
|
||||
for (const item of pageData.data) {
|
||||
results.push({
|
||||
href: `https://animepahe.si/play/${id}/${item.session}`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue