diff --git a/animepahe/animepahe.js b/animepahe/animepahe.js index 51b0ed3..3d202a8 100644 --- a/animepahe/animepahe.js +++ b/animepahe/animepahe.js @@ -129,15 +129,13 @@ async function extractStreamUrl(url) { return JSON.stringify({ streams: [], subtitle: "" }); } - const streams = []; - - for (const buttonHtml of buttonMatches) { + const streamPromises = buttonMatches.map(async (buttonHtml) => { const srcMatch = buttonHtml.match(/data-src="([^"]*)"/); const resMatch = buttonHtml.match(/data-resolution="([^"]*)"/); const audioMatch = buttonHtml.match(/data-audio="([^"]*)"/); const fansubMatch = buttonHtml.match(/data-fansub="([^"]*)"/); - if (!srcMatch || !srcMatch[1].includes('kwik.cx')) continue; + if (!srcMatch || !srcMatch[1].includes('kwik.cx')) return null; const kwikUrl = srcMatch[1]; const resolution = resMatch ? resMatch[1] : "Unknown"; @@ -171,21 +169,25 @@ async function extractStreamUrl(url) { const audioType = audio === "eng" ? "Dub" : "Hardsub"; const title = `${resolution}p • ${audioType}`; - streams.push({ + return { title: title, streamUrl: hlsUrl, headers: { "Referer": "https://kwik.cx/", "Origin": "https://kwik.cx" } - }); + }; } } } } catch (e) { - continue; + // Continue to next } - } + return null; + }); + + const streamResults = await Promise.all(streamPromises); + const streams = streamResults.filter(s => s !== null); return JSON.stringify({ streams: streams,