diff --git a/donghuanosekai/donghuanosekai.js b/donghuanosekai/donghuanosekai.js new file mode 100644 index 0000000..89f226b --- /dev/null +++ b/donghuanosekai/donghuanosekai.js @@ -0,0 +1,107 @@ +async function searchResults(keyword) { + const results = []; + try { + const response = await fetchv2(`https://donghuanosekai.com/wp-json/site/search/?keyword=${encodeURIComponent(keyword)}&type=undefined&nonce=4c4380bfaa`); + const data = await response.json(); + + for (const key in data) { + if (data.hasOwnProperty(key)) { + const item = data[key]; + results.push({ + title: item.title, + image: item.img, + href: item.url + }); + } + } + + 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 regex = /
([\s\S]*?)<\/p>/i; + const match = html.match(regex); + 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(url) { + const results = []; + try { + const response = await fetchv2(url); + const html = await response.text(); + + const regex = /]*>\s*.*?Episódio\s+(\d+)<\/span>/g; + let match; + while ((match = regex.exec(html)) !== null) { + results.push({ + href: match[1].trim(), + number: parseInt(match[2], 10) + }); + } + + return JSON.stringify(results.reverse()); + } 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 divRegex = /