]*id="app"[^>]*data-page="([^"]*)"/;
const match = regex.exec(html);
- if (!match?.[1]) return JSON.stringify([]);
+ if (!match || !match[1]) {
+ return JSON.stringify([]);
+ }
- const pageData = JSON.parse(match[1].replaceAll(`"`, `"`));
+ const dataPage = match[1].replaceAll(`"`, `"`);
+ const pageData = JSON.parse(dataPage);
+ const titles = pageData.props?.titles || [];
+
+ const results =
+ titles
+ .map((item) => {
+ const posterImage = item.images?.find((img) => img.type === "poster");
+ return {
+ title: item.name?.replaceAll("amp;", "").replaceAll("'", "'") || "",
+ image: posterImage?.filename ?
+ `https://cdn.${landingUrl}/images/${posterImage.filename}` :
+ "",
+ href: `https://${landingUrl}/it/titles/${item.id}-${item.slug}`,
+ };
+ })
+ .filter((item) => item.image) || [];
+
+ return JSON.stringify(results);
+}
+
+async function extractDetails(url) {
+ const baseUrl = await getLandingWebsiteHref()
+
+ const response = await soraFetch(`${url}/season-1`);
+ const html = await response.text();
+
+ const regex = /
]*id="app"[^>]*data-page="([^"]*)"/;
+ const match = regex.exec(html);
+
+ if (!match || !match[1]) {
+ return JSON.stringify([]);
+ }
+
+ const dataPage = match[1].replaceAll(`"`, `"`);
+ const pageData = JSON.parse(dataPage);
const titleData = pageData.props?.title;
- if (!titleData) return JSON.stringify([]);
- const titleId = titleData.id;
- const totalSeasons = titleData.seasons_count || 1;
+ if (!titleData) {
+ return JSON.stringify([]);
+ }
- let hasEpisodes = false;
+ return JSON.stringify([{
+ description: titleData.plot?.replaceAll("amp;", "").replaceAll("'", "'") ||
+ "N/A",
+ aliases: titleData.original_name
+ ?.replaceAll("amp;", "")
+ .replaceAll("'", "'") || "N/A",
+ airdate: titleData.release_date || "N/A",
+ }, ]);
+}
- for (let season = 1; season <= totalSeasons; season++) {
- try {
- const seasonResponse = await soraFetch(`${baseUrl}/season-${season}`);
- const seasonHtml = await seasonResponse.text();
- const seasonMatch = regex.exec(seasonHtml);
+async function extractEpisodes(url) {
+ try {
+ const landingUrl = await getLandingWebsiteHref()
- if (seasonMatch?.[1]) {
- const seasonData = JSON.parse(
- seasonMatch[1].replaceAll(`"`, `"`)
- );
- const seasonEpisodes = seasonData.props?.loadedSeason?.episodes || [];
+ const episodes = [];
+ const baseUrl = url.replace(/\/season-\d+$/, "");
- if (seasonEpisodes.length > 0) {
- hasEpisodes = true;
- seasonEpisodes.forEach((episode) => {
- episodes.push({
- href: `https://streamingcommunityz.kitchen/it/iframe/${titleId}?episode_id=${episode.id}`,
- number: episode.number || episodes.length + 1,
- });
- });
- }
+ const response = await soraFetch(`${baseUrl}/season-1`);
+ const html = await response.text();
+ const regex = /
]*id="app"[^>]*data-page="([^"]*)"/;
+ const match = regex.exec(html);
+
+ if (!match?.[1]) return JSON.stringify([]);
+
+ const pageData = JSON.parse(match[1].replaceAll(`"`, `"`));
+ const titleData = pageData.props?.title;
+ if (!titleData) return JSON.stringify([]);
+
+ const titleId = titleData.id;
+ const totalSeasons = titleData.seasons_count || 1;
+
+ let hasEpisodes = false;
+
+ for (let season = 1; season <= totalSeasons; season++) {
+ try {
+ const seasonResponse = await soraFetch(`${baseUrl}/season-${season}`);
+ const seasonHtml = await seasonResponse.text();
+ const seasonMatch = regex.exec(seasonHtml);
+
+ if (seasonMatch?.[1]) {
+ const seasonData = JSON.parse(
+ seasonMatch[1].replaceAll(`"`, `"`)
+ );
+ const seasonEpisodes = seasonData.props?.loadedSeason?.episodes || [];
+
+ if (seasonEpisodes.length > 0) {
+ hasEpisodes = true;
+ seasonEpisodes.forEach((episode) => {
+ episodes.push({
+ href: `https://${landingUrl}/it/iframe/${titleId}?episode_id=${episode.id}`,
+ number: episode.number || episodes.length + 1,
+ });
+ });
+ }
+ }
+ } catch (error) {
+ console.log(`Error fetching season ${season}:`, error);
+ }
}
- } catch (error) {
- console.log(`Error fetching season ${season}:`, error);
- }
- }
- if (!hasEpisodes) {
- episodes.push({
- href: `https://streamingcommunityz.kitchen/it/iframe/${titleId}`,
- number: 1,
- });
- }
+ if (!hasEpisodes) {
+ episodes.push({
+ href: `https://${landingUrl}/it/iframe/${titleId}`,
+ number: 1,
+ });
+ }
- return JSON.stringify(episodes);
- } catch (error) {
- console.log("Error extracting episodes:", error);
- return JSON.stringify([]);
- }
+ return JSON.stringify(episodes);
+ } catch (error) {
+ console.log("Error extracting episodes:", error);
+ return JSON.stringify([]);
+ }
}
async function extractStreamUrl(url) {
- try {
- let modifiedUrl = url;
- if (!url.includes("/it/iframe") && !url.includes("/en/iframe")) {
- modifiedUrl = url.replace("/iframe", "/it/iframe");
- }
- const response1 = await soraFetch(modifiedUrl);
- const html1 = await response1.text();
+ try {
+ let modifiedUrl = url;
+ if (!url.includes("/it/iframe") && !url.includes("/en/iframe")) {
+ modifiedUrl = url.replace("/iframe", "/it/iframe");
+ }
+ const response1 = await soraFetch(modifiedUrl);
+ const html1 = await response1.text();
- const iframeMatch = html1.match(/