diff --git a/animegg/animegg.js b/animegg/animegg.js new file mode 100644 index 0000000..c5a6eb5 --- /dev/null +++ b/animegg/animegg.js @@ -0,0 +1,118 @@ +async function searchResults(keyword) { + const regex = /[\s\S]*?[\s\S]*?

([^<]*?)<\/h2>/g; + const results = []; + try { + const response = await fetchv2("https://www.animegg.org/search/?q=" + encodeURIComponent(keyword)); + const html = await response.text(); + + let match; + while ((match = regex.exec(html)) !== null) { + results.push({ + title: match[3].trim(), + image: match[2].trim(), + href: "https://www.animegg.org" + match[1].trim() + }); + } + + return JSON.stringify(results); + } catch (err) { + return JSON.stringify([{ + title: "Error", + image: "Error", + href: "Error" + }]); + } +} + +async function extractDetails(url) { + try { + const response = await fetchv2(url); + const html = await response.text(); + + const descMatch = html.match(/

(.*?)<\/p>/s); + const description = descMatch ? descMatch[1].trim() : "N/A"; + + return JSON.stringify([{ + description: description, + aliases: "N/A", + airdate: "N/A" + }]); + } catch (err) { + return JSON.stringify([{ + description: "Error", + aliases: "Error", + airdate: "Error" + }]); + } +} + +async function extractEpisodes(url) { + const results = []; + try { + const response = await fetchv2(url); + const html = await response.text(); + + const regex = /[\s\S]*?(Episode (\d+)|Movie)<\/i>/g; + let match; + while ((match = regex.exec(html)) !== null) { + const href = "https://www.animegg.org" + match[1].trim(); + let number; + if (match[2] === "Movie") { + number = 1; + } else { + number = parseInt(match[3], 10); + } + results.push({ + href: href, + number: number + }); + } + + return JSON.stringify(results); + } catch (err) { + return JSON.stringify([{ + href: "Error", + number: "Error" + }]); + } +} + +async function extractStreamUrl(url) { + try { + const response = await fetchv2(url); + const html = await response.text(); + const ulMatch = html.match(/