([\s\S]*?)<\/div>\s*/g;
+ let containerMatch;
+ while ((containerMatch = itemContainerRegex.exec(html)) !== null) {
+ const itemHtml = containerMatch[1];
+
+ const hrefMatch = itemHtml.match(/
]+src="([^"]+)"/);
+ const image = imgMatch ? imgMatch[1].trim() : null;
+
+ const titleMatch = itemHtml.match(/]*>([^<]+)<\/h3>/);
+ const title = titleMatch ? titleMatch[1].trim() : null;
+
+ if (href && image && title) {
+ results.push({
+ href: href,
+ image: image,
+ title: title
+ });
+ }
+ }
+
+ 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 = /
(.*?)<\/p>/s;
+ 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 itemContainerRegex = /
[\s\S]*?
Season\s+(\d+)<\/span>[\s\S]*?Episode\s+(\d+)<\/span>[\s\S]*?<\/div>/g;
+ let containerMatch;
+ while ((containerMatch = itemContainerRegex.exec(html)) !== null) {
+ const href = containerMatch[1].trim();
+ const season = parseInt(containerMatch[2], 10);
+ const episode = parseInt(containerMatch[3], 10);
+
+ results.push({
+ href: href,
+ season: season,
+ number: episode
+ });
+ }
+
+ if (results.length === 0) {
+ results.push({
+ href: url,
+ season: 1,
+ number: 1
+ });
+ }
+
+ return JSON.stringify(results);
+ } catch (err) {
+ return JSON.stringify([{
+ href: "Error",
+ season: "Error",
+ number: "Error"
+ }]);
+ }
+}
+
+async function extractStreamUrl(url) {
+ try {
+ const response = await fetchv2(url);
+ const html = await response.text();
+
+ const snapshotMatch = html.match(/wire:snapshot="(.+?)" wire:effects/);
+ if (!snapshotMatch) {
+ return "https://error.org/";
+ }
+
+ const decodedSnapshot = snapshotMatch[1]
+ .replace(/"/g, '"')
+ .replace(/\\\//g, '/')
+ .replace(/</g, '<')
+ .replace(/>/g, '>')
+ .replace(/&/g, '&');
+
+ const data = JSON.parse(decodedSnapshot);
+
+ const videosArray = data.data.videos[0];
+ let fmLink = null;
+
+ for (let i = 0; i < videosArray.length; i++) {
+ const item = videosArray[i];
+
+ if (Array.isArray(item) && item.length > 0) {
+ const videoObj = item[0];
+ if (videoObj && videoObj.label === "FM") {
+ fmLink = videoObj.link;
+ break;
+ }
+ }
+ else if (item && item.label === "FM") {
+ fmLink = item.link;
+ break;
+ }
+ }
+
+ console.log("FM Stream Link: " + fmLink);
+
+ if (fmLink) {
+ try {
+ const embedResponse = await fetchv2(fmLink);
+ const embedHtml = await embedResponse.text();
+
+ const iframeSrcMatch = embedHtml.match(/