diff --git a/anroll/anroll.js b/anroll/anroll.js new file mode 100644 index 0000000..1314630 --- /dev/null +++ b/anroll/anroll.js @@ -0,0 +1,175 @@ +async function searchResults(keyword) { + const results = []; + try { + const response = await fetchv2("https://api-search.anroll.net/data?q=" + encodeURIComponent(keyword)); + const data = await response.json(); + + data.data.forEach(item => { + const baseUrl = item.generic_path.trim().startsWith('/f/') + ? "https://www.anroll.net/_next/image?url=https://static.anroll.net/images/filmes/capas/" + : "https://www.anroll.net/_next/image?url=https://static.anroll.net/images/animes/capas/"; + + results.push({ + title: item.title.trim(), + image: baseUrl + item.slug.trim() + ".jpg&w=384&q=75", + href: item.generic_path.trim() + }); + }); + + return JSON.stringify(results); + } catch (err) { + return JSON.stringify([{ + title: "Error", + image: "Error", + href: "Error" + }]); + } +} + +async function extractDetails(slug) { + try { + const response = await fetchv2("https://www.anroll.net/" + slug); + const html = await response.text(); + + const match = html.match(/
(.*?)<\/div>/s); + const description = match ? match[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(slug) { + const results = []; + try { + // If slug starts with /f/ (movie), extract ID and return as single episode + if (slug.startsWith('/f/')) { + results.push({ + href: slug, + number: 1 + }); + return JSON.stringify(results); + } + + // Only process if slug starts with /a/ (anime) + if (!slug.startsWith('/a/')) { + return JSON.stringify(results); + } + + const response = await fetchv2("https://www.anroll.net" + slug); + const html = await response.text(); + + // Extract series ID from __NEXT_DATA__ + const scriptMatch = html.match(/