/** * OppaDrama K-Drama Scraper & Video Stream Extractor (Dual CJS/ESM Support) * Author: Vamz Spectre / VamxAPI * Website: https://vamxapi.my.id * Channel: https://whatsapp.com/channel/0029Vb8n36OGE56uvRAq4y3y */ const BASE_URL = "https://oppadrama.io"; const HEADERS = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language": "id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7", }; /** * 1. Get Latest Episode Releases (Update Terbaru di Homepage) * @param {number} page */ async function getLatestUpdates(page = 1) { const url = page > 1 ? `${BASE_URL}/page/${page}/` : `${BASE_URL}/`; const res = await fetch(url, { headers: HEADERS, signal: AbortSignal.timeout(15000) }); if (!res.ok) throw new Error(`HTTP Error ${res.status}`); const html = await res.text(); const results = []; const cards = html.match(/
[\s\S]*?<\/div>\s*<\/div>/gi) || []; for (const card of cards) { const title = card.match(/title="([^"]+)"/i)?.[1]?.trim(); const link = card.match(/href="([^"]+)"/i)?.[1]?.trim(); const poster = card.match(/src="([^"]+)"/i)?.[1]?.trim() || card.match(/data-src="([^"]+)"/i)?.[1]?.trim(); const type = card.match(/class="typez ([^"]+)"/i)?.[1]?.trim() || "Episode"; const status = card.match(/class="bt [^"]*">([^<]+)<\/span>/i)?.[1]?.trim(); const ep = card.match(/class="epx">([^<]+)<\/span>/i)?.[1]?.trim(); if (title && link) { results.push({ title, url: link, poster: poster || null, type, status: status || null, episode_label: ep || null, }); } } return { status: true, page: Number(page), total: results.length, results, }; } /** * 2. Get Drama by Category / Country / Status * @param {object} filter { status: 'Ongoing'|'Completed', country: 'south-korea'|'china'|'japan'|'thailand', page: 1 } */ async function getDramaList(filter = {}) { const { status = "", country = "", page = 1 } = filter; const params = new URLSearchParams(); if (status) params.append("status", status); if (country) params.append("country[]", country); params.append("type", "Drama"); params.append("order", "update"); if (page > 1) params.append("page", page); const url = `${BASE_URL}/series/?${params.toString()}`; const res = await fetch(url, { headers: HEADERS, signal: AbortSignal.timeout(15000) }); if (!res.ok) throw new Error(`HTTP Error ${res.status}`); const html = await res.text(); const results = []; const cards = html.match(/
[\s\S]*?<\/div>\s*<\/div>/gi) || []; for (const card of cards) { const title = card.match(/title="([^"]+)"/i)?.[1]?.trim(); const link = card.match(/href="([^"]+)"/i)?.[1]?.trim(); const poster = card.match(/src="([^"]+)"/i)?.[1]?.trim() || card.match(/data-src="([^"]+)"/i)?.[1]?.trim(); const type = card.match(/class="typez ([^"]+)"/i)?.[1]?.trim() || "Drama"; const statusLabel = card.match(/class="bt [^"]*">([^<]+)<\/span>/i)?.[1]?.trim(); if (title && link) { results.push({ title, url: link, poster: poster || null, type, status: statusLabel || null, }); } } return { status: true, filter: { status, country, page: Number(page) }, total: results.length, results, }; } /** * 3. Search Drama Korea by Keyword * @param {string} query */ async function searchDrama(query) { if (!query || !query.trim()) throw new Error("Kata kunci pencarian tidak boleh kosong"); const url = `${BASE_URL}/?s=${encodeURIComponent(query.trim())}`; const res = await fetch(url, { headers: HEADERS, signal: AbortSignal.timeout(15000) }); if (!res.ok) throw new Error(`HTTP Error ${res.status}`); const html = await res.text(); const results = []; const cards = html.match(/
[\s\S]*?<\/div>\s*<\/div>/gi) || []; for (const card of cards) { const title = card.match(/title="([^"]+)"/i)?.[1]?.trim(); const link = card.match(/href="([^"]+)"/i)?.[1]?.trim(); const poster = card.match(/src="([^"]+)"/i)?.[1]?.trim() || card.match(/data-src="([^"]+)"/i)?.[1]?.trim(); const type = card.match(/class="typez ([^"]+)"/i)?.[1]?.trim() || "Drama"; const status = card.match(/class="bt [^"]*">([^<]+)<\/span>/i)?.[1]?.trim(); const ep = card.match(/class="epx">([^<]+)<\/span>/i)?.[1]?.trim(); if (title && link) { results.push({ title, url: link, poster: poster || null, type, status: status || null, episode_label: ep || null, }); } } return { status: true, total: results.length, results, }; } /** * 4. Get Drama Detail & Full Episode List * @param {string} seriesUrl (e.g. https://oppadrama.io/series/salon-de-nabi/) */ async function getDramaDetail(seriesUrl) { if (!seriesUrl || !seriesUrl.trim()) throw new Error("URL Series wajib diisi"); const res = await fetch(seriesUrl, { headers: HEADERS, signal: AbortSignal.timeout(15000) }); if (!res.ok) throw new Error(`HTTP Error ${res.status}`); const html = await res.text(); const title = html.match(/]*class=["']entry-title["'][^>]*>([\s\S]*?)<\/h1>/i)?.[1]?.trim(); const poster = html.match(/
]*>[\s\S]*?]+src=["']([^"']+)["']/i)?.[1]; const synopsis = html.match(/
]*>([\s\S]*?)<\/div>/i)?.[1]?.replace(/<[^>]+>/g, "").trim(); // Extract Metadata Info const rating = html.match(/class="rating">[\s\S]*?([^<]+)<\/strong>/i)?.[1]?.trim(); const status = html.match(/Status:<\/b>([\s\S]*?)<\/span>/i)?.[1]?.trim(); const network = html.match(/Network:<\/b>([\s\S]*?)<\/span>/i)?.[1]?.trim(); const country = html.match(/Country:<\/b>([\s\S]*?)<\/span>/i)?.[1]?.trim(); // Extract Episodes const episodes = []; const epMatches = html.match(/]*data-index="[^"]*"[^>]*>[\s\S]*?<\/li>/gi) || []; for (const epHtml of epMatches) { const link = epHtml.match(/href=["']([^"']+)["']/i)?.[1]?.trim(); const epNum = epHtml.match(/
([^<]+)<\/div>/i)?.[1]?.trim(); const epTitle = epHtml.match(/
([^<]+)<\/div>/i)?.[1]?.trim(); const epDate = epHtml.match(/
([^<]+)<\/div>/i)?.[1]?.trim(); if (link) { episodes.push({ episode: epNum || null, title: epTitle || null, release_date: epDate || null, url: link, }); } } return { status: true, title: title || "—", poster: poster || null, rating: rating || null, status: status || null, network: network || null, country: country || null, synopsis: synopsis || null, total_episodes: episodes.length, episodes, }; } /** * 5. Get Episode Streaming Stream & Download Links * @param {string} episodeUrl (e.g. https://oppadrama.io/salon-de-nabi-episode-6/) */ async function getEpisodeStream(episodeUrl) { if (!episodeUrl || !episodeUrl.trim()) throw new Error("URL Episode wajib diisi"); const res = await fetch(episodeUrl, { headers: HEADERS, signal: AbortSignal.timeout(15000) }); if (!res.ok) throw new Error(`HTTP Error ${res.status}`); const html = await res.text(); const title = html.match(/]*class=["']entry-title["'][^>]*>([\s\S]*?)<\/h1>/i)?.[1]?.trim(); // Streaming Mirrors const streams = []; const select = html.match(/