mirror of
https://git.luna-app.eu/50n50/sources
synced 2026-01-12 09:28:35 +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;
|
const lastPage = data1.last_page;
|
||||||
if (lastPage > 1) {
|
if (lastPage > 1) {
|
||||||
|
const pagePromises = [];
|
||||||
for (let p = 2; p <= lastPage; p++) {
|
for (let p = 2; p <= lastPage; p++) {
|
||||||
let pageData = null;
|
pagePromises.push((async (pageNum) => {
|
||||||
let retries = 0;
|
let pageData = null;
|
||||||
while (!pageData && retries < 3) {
|
let retries = 0;
|
||||||
try {
|
while (!pageData && retries < 3) {
|
||||||
const apiUrl = `https://animepahe.si/api?m=release&id=${id}&sort=episode_asc&page=${p}`;
|
try {
|
||||||
const response = await ddosInterceptor.fetchWithBypass(apiUrl);
|
const apiUrl = `https://animepahe.si/api?m=release&id=${id}&sort=episode_asc&page=${pageNum}`;
|
||||||
const dataText = await response.text();
|
const response = await ddosInterceptor.fetchWithBypass(apiUrl);
|
||||||
pageData = JSON.parse(dataText);
|
const dataText = await response.text();
|
||||||
} catch (pageErr) {
|
pageData = JSON.parse(dataText);
|
||||||
retries++;
|
} catch (pageErr) {
|
||||||
|
retries++;
|
||||||
|
if (retries < 3) {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 500));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return pageData;
|
||||||
if (pageData) {
|
})(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
const allPagesData = await Promise.all(pagePromises);
|
||||||
|
for (const pageData of allPagesData) {
|
||||||
|
if (pageData && pageData.data) {
|
||||||
for (const item of pageData.data) {
|
for (const item of pageData.data) {
|
||||||
results.push({
|
results.push({
|
||||||
href: `https://animepahe.si/play/${id}/${item.session}`,
|
href: `https://animepahe.si/play/${id}/${item.session}`,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue