/** * ======================================================== * Name: DongWorld Scraper & Donghua Stream Extractor * * Cara Download: * curl -sL "https://code.vamxapi.my.id/snippet/raw/dongworld-scraper" -o dongworld-scraper.js * * Cara Eksekusi: * node dongworld-scraper.js "Battle Through The Heavens" * * Author: Vamz Spectre * Source: https://vamxapi.my.id * ======================================================== */ async function fetchHtml(urlStr) { const res = await fetch(urlStr, { headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language": "id,en-US;q=0.9,en;q=0.8" } }); return await res.text(); } /** * 1. SEARCH: Cari Donghua berdasarkan judul */ async function searchDonghua(query, page = 1) { const url = `https://dongworld.top/series?search=${encodeURIComponent(query)}&page=${page}`; const html = await fetchHtml(url); const unescaped = html.replace(/\\"/g, "\""); const cards = []; const cardRegex = /href="\/series\/([^"]+)"[\s\S]*?alt="([^"]+)"[\s\S]*?src="([^"]+)"[\s\S]*?class="dl-card-title">([^<]+)<[\s\S]*?span>([^<]+eps)<[\s\S]*?fa-star"><\/i>([^<]+)/g, "").trim(), rating: m[6].trim(), url: `https://dongworld.top/series/${slug}` }); } } return { status: true, query, page, totalResults: cards.length, results: cards }; } /** * 2. KATALOG: Ambil Daftar Semua Donghua */ async function getLatestDonghua(page = 1) { const url = `https://dongworld.top/series?page=${page}`; const html = await fetchHtml(url); const unescaped = html.replace(/\\"/g, "\""); const cards = []; const cardRegex = /href="\/series\/([^"]+)"[\s\S]*?alt="([^"]+)"[\s\S]*?src="([^"]+)"[\s\S]*?class="dl-card-title">([^<]+)<[\s\S]*?span>([^<]+eps)<[\s\S]*?fa-star"><\/i>([^<]+)/g, "").trim(), rating: m[6].trim(), url: `https://dongworld.top/series/${slug}` }); } } return { status: true, page, total: cards.length, donghua: cards }; } /** * 3. DETAIL: Ambil Detail Donghua, Sinopsis, dan Seluruh Daftar Episode */ async function getDonghuaDetail(seriesSlug) { const url = `https://dongworld.top/series/${seriesSlug}`; const html = await fetchHtml(url); const unescaped = html.replace(/\\"/g, "\""); // Metadata Series let series = null; const seriesIdx = unescaped.indexOf('"series":{'); if (seriesIdx !== -1) { try { const braceEnd = unescaped.indexOf('}}]}', seriesIdx); if (braceEnd !== -1) { series = JSON.parse(unescaped.slice(seriesIdx + 9, braceEnd + 1)); } } catch (_) {} } // Synopsis let synopsis = ""; const synMatch = unescaped.match(/class="dl-details-synopsis"[\s\S]*?"text":"([^"]+)"/); if (synMatch) { synopsis = synMatch[1].replace(/\\n/g, "\n"); } // Episode List const episodes = []; const epRegex = /"episode_number":(\d+),"download_links":null,"slug":"([^"]+)"/g; let epMatch; while ((epMatch = epRegex.exec(unescaped)) !== null) { episodes.push({ episodeNumber: parseInt(epMatch[1], 10), slug: epMatch[2], watchUrl: `https://dongworld.top/watch/${epMatch[2]}` }); } return { status: true, slug: seriesSlug, title: series?.name || seriesSlug, rating: series?.rating || null, statusDonghua: series?.status || null, genres: series?.genres_string ? series.genres_string.split(", ") : [], totalEpisodes: episodes.length, synopsis, episodes }; } /** * 4. STREAM & DOWNLOAD: Ambil Embed Player & Link Download Google Drive */ async function getEpisodeStream(watchSlug) { const url = `https://dongworld.top/watch/${watchSlug}`; const html = await fetchHtml(url); const unescaped = html.replace(/\\"/g, "\""); // Ekstraksi Embed Stream Links const links = []; const linksIdx = unescaped.indexOf('"links":['); if (linksIdx !== -1) { try { const closeIdx = unescaped.indexOf('],"downloads":', linksIdx); if (closeIdx !== -1) { const rawJson = unescaped.slice(linksIdx + 8, closeIdx + 1); const parsed = JSON.parse(rawJson); parsed.forEach(item => { links.push({ server: item.server?.name || "Unknown", url: item.url }); }); } } catch (_) {} } // Ekstraksi Download Links (Google Drive, dll) const downloads = []; const downIdx = unescaped.indexOf('"downloads":['); if (downIdx !== -1) { try { const closeDown = unescaped.indexOf('],"comments":', downIdx); if (closeDown !== -1) { const rawDown = unescaped.slice(downIdx + 12, closeDown + 1); const parsedDown = JSON.parse(rawDown); parsedDown.forEach(d => { downloads.push({ server: d.server || "Google Drive", quality: d.quality || "HD", link: d.link }); }); } } catch (_) {} } return { status: true, slug: watchSlug, streamServers: links, downloadLinks: downloads }; } if (typeof module !== "undefined" && module.exports) { module.exports = { searchDonghua, getDonghuaDetail, getEpisodeStream }; } /** * CLI Runner: * Langsung eksekusi jika dijalankan via terminal: node dongworld-scraper.js "judul" */ const argDonghua = process.argv[2]; if (argDonghua) { (async () => { try { if (argDonghua.includes("episode-") || argDonghua.includes("/episode/")) { const epSlug = argDonghua.split("/").filter(Boolean).pop(); const res = await getEpisodeStream(epSlug); console.log(JSON.stringify(res, null, 2)); } else if (argDonghua.startsWith("http") || argDonghua.includes("-sub-indo")) { const seriesSlug = argDonghua.split("/").filter(Boolean).pop(); const res = await getDonghuaDetail(seriesSlug); console.log(JSON.stringify(res, null, 2)); } else { const res = await searchDonghua(argDonghua); console.log(JSON.stringify(res, null, 2)); } } catch (err) { console.error(JSON.stringify({ success: false, error: err.message }, null, 2)); process.exit(1); } })(); } else if (process.argv[1] && process.argv.length <= 2) { console.log("Usage: node dongworld-scraper.js \"\""); }