/** * ======================================================== * Name: CineSubz Movie, TV Shows & Stream Download Scraper * * Cara Download: * curl -sL "https://code.vamxapi.my.id/snippet/raw/cinesubz-movie-scraper" -o cinesubz-movie-scraper.js * * Cara Eksekusi: * node cinesubz-movie-scraper.js search "Spider-Man" * node cinesubz-movie-scraper.js detail "https://cinesubz.net/movies/spider-man-brand-new-day-2026-sinhala-subtitles/" * node cinesubz-movie-scraper.js latest movies 1 * node cinesubz-movie-scraper.js resolve "https://cinesubz.net/zt-links/nvm2e3d9ep/" * * Author: Vamz Spectre * Source: https://vamxapi.my.id * ======================================================== */ const BASE_URL = "https://cinesubz.net"; const DEFAULT_HEADERS = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36", Accept: "text/html,application/json,*/*", "Accept-Language": "en-US,en;q=0.9", }; const URL_MAPPINGS = [ { search: ["https://google.com/server11/1:/", "https://google.com/server12/1:/", "https://google.com/server13/1:/"], replace: "https://drive.csplayer2.space/server1/" }, { search: ["https://google.com/server21/1:/", "https://google.com/server22/1:/", "https://google.com/server23/1:/"], replace: "https://drive.csplayer2.space/server2/" }, { search: ["https://google.com/server3/1:/"], replace: "https://drive.csplayer2.space/server3/" }, { search: ["https://google.com/server4/1:/"], replace: "https://drive.csplayer2.space/server4/" }, { search: ["https://google.com/server5/1:/"], replace: "https://drive.csplayer2.space/server5/" }, { search: ["https://google.com/server6/"], replace: "https://drive.csplayer2.space/server6/" }, { search: ["https://google.com/server7/"], replace: "https://drive.csplayer2.space/server7/" } ]; let cachedNonce = null; let nonceExpires = 0; /** * Ambil fresh security nonce dari frontend Zetaflix */ async function getNonce() { const now = Date.now(); if (cachedNonce && now < nonceExpires) { return cachedNonce; } try { const res = await fetch(BASE_URL, { headers: DEFAULT_HEADERS }); const html = await res.text(); const match = html.match(/var ztGo\s*=\s*({[^;]+});/); if (match) { const obj = JSON.parse(match[1]); if (obj.nonce) { cachedNonce = obj.nonce; nonceExpires = now + 15 * 60 * 1000; return cachedNonce; } } } catch {} return "11c13d6e10"; } /** * 1. Search Movie / TV Shows */ async function search(query) { const cleanQ = (query || "").trim(); if (!cleanQ) throw new Error("Query pencarian tidak boleh kosong!"); const nonce = await getNonce(); const searchUrl = `${BASE_URL}/wp-json/zetaflix/search/?keyword=${encodeURIComponent(cleanQ)}&nonce=${nonce}`; const res = await fetch(searchUrl, { headers: DEFAULT_HEADERS }); if (!res.ok) throw new Error(`Pencarian gagal: HTTP ${res.status}`); const data = await res.json(); if (data.error) throw new Error(data.title || "Gagal melakukan pencarian"); const results = Object.entries(data) .map(([id, item]) => { const genres = item.extra?.genres ? item.extra.genres.split(",").map(g => g.trim()) : []; const isAdult = genres.some(g => g.toLowerCase() === "18" || g.toLowerCase() === "18+"); return { id, title: item.title, url: item.url, thumbnail: item.img, genres, year: item.extra?.date || null, imdb_rating: item.extra?.imdb || null, runtime: item.extra?.runtime ? item.extra.runtime.replace(/tt\d+\s*/, "") : null, is_adult: isAdult }; }) .filter(item => !item.is_adult); return { status: true, query: cleanQ, total: results.length, results }; } /** * 2. Get Latest Movies or TV Shows */ async function getLatest(type = "movies", page = 1) { const targetType = type === "tvshows" ? "tvshows" : "movies"; const url = page > 1 ? `${BASE_URL}/${targetType}/page/${page}/` : `${BASE_URL}/${targetType}/`; const res = await fetch(url, { headers: DEFAULT_HEADERS }); if (!res.ok) throw new Error(`Gagal mengambil data katalog: HTTP ${res.status}`); const html = await res.text(); const items = []; const regex = /]*id=["']item-(\d+)["'][^>]*>([\s\S]*?)<\/div>\s*<\/div>/gi; let m; while ((m = regex.exec(html)) !== null) { const id = m[1]; const block = m[2]; const linkMatch = block.match(/]*href=["']([^"']+)["'][^>]*title=["']([^"']+)["']/i); const imgMatch = block.match(/]*src=["']([^"']+)["']/i); const qualityMatch = block.match(/]*class=["']badge-quality-corner["'][^>]*>([\s\S]*?)<\/span>/i); const imdbMatch = block.match(/]*class=["']imdb-score["'][^>]*>([\s\S]*?)<\/span>/i); if (linkMatch) { items.push({ id, title: linkMatch[2].trim(), url: linkMatch[1], thumbnail: imgMatch ? imgMatch[1] : null, quality: qualityMatch ? qualityMatch[1].trim() : null, imdb_rating: imdbMatch ? imdbMatch[1].trim() : null }); } } return { status: true, type: targetType, page: Number(page) || 1, total: items.length, results: items }; } /** * 3. Resolve Direct Stream / Download dari ZT-Links & Safe Redirector */ async function resolveZtLink(rawUrl) { if (!rawUrl) throw new Error("URL zt-link wajib disertakan!"); let ztUrl = rawUrl.trim().replace("cinesubz.lk", "cinesubz.net"); const res = await fetch(ztUrl, { headers: { ...DEFAULT_HEADERS, Referer: "https://cinesubz.net/", }, }); if (!res.ok) throw new Error(`Gagal membuka link zt-links: HTTP ${res.status}`); const html = await res.text(); const linkMatch = html.match(/]*id=["']link["'][^>]*href=["']([^"']+)["']/i); if (!linkMatch) throw new Error("Link unduhan tidak ditemukan di dalam halaman (mungkin sudah kedaluwarsa)."); const originalUrl = linkMatch[1]; let finalUrl = originalUrl; for (const mapping of URL_MAPPINGS) { for (const searchUrl of mapping.search) { if (finalUrl.includes(searchUrl)) { finalUrl = finalUrl.replace(searchUrl, mapping.replace); if (finalUrl.includes(".mp4?bot=cscloud2bot&code=")) { finalUrl = finalUrl.replace(".mp4?bot=cscloud2bot&code=", "?ext=mp4&bot=cscloud2bot&code="); } else if (finalUrl.includes(".mp4")) { finalUrl = finalUrl.replace(".mp4", "?ext=mp4"); } else if (finalUrl.includes(".mkv?bot=cscloud2bot&code=")) { finalUrl = finalUrl.replace(".mkv?bot=cscloud2bot&code=", "?ext=mkv&bot=cscloud2bot&code="); } else if (finalUrl.includes(".mkv")) { finalUrl = finalUrl.replace(".mkv", "?ext=mkv"); } else if (finalUrl.includes(".zip")) { finalUrl = finalUrl.replace(".zip", "?ext=zip"); } break; } } } return { status: true, zt_url: rawUrl, original_url: originalUrl, direct_stream_url: finalUrl, is_telegram: originalUrl.includes("t.me") }; } /** * 4. Get Movie or TV Show Detail & Download Links */ async function getDetail(targetUrl) { let url = targetUrl.trim(); if (!url.startsWith("http")) { url = `${BASE_URL}/movies/${url.replace(/^\//, "").replace(/\/$/, "")}/`; } const res = await fetch(url, { headers: DEFAULT_HEADERS }); if (!res.ok) throw new Error(`Gagal mengakses detail: HTTP ${res.status}`); const html = await res.text(); // Parse Title (prioritize og:title / title tag as Zetaflix uses h1 for CTA button) const ogTitleMatch = html.match(/([^<]+)<\/title>/i); let title = "Unknown Title"; if (ogTitleMatch && ogTitleMatch[1]) { title = ogTitleMatch[1].replace(/–/g, "-").replace(/’/g, "'").trim(); } else if (titleTagMatch && titleTagMatch[1]) { title = titleTagMatch[1].replace(/–/g, "-").replace(/’/g, "'").trim(); } else { const titleMatch = html.match(/]*class=["']entry-title["'][^>]*>([\s\S]*?)<\/h1>/i); title = titleMatch ? titleMatch[1].replace(/<[^>]+>/g, "").trim() : "Unknown Title"; } // Parse Poster & Backdrop const posterMatch = html.match(/]*class=["'][^"']*poster[^"']*["'][^>]*src=["']([^"']+)["']/i) || html.match(/
[\s\S]*?]*src=["']([^"']+)["']/i); const backdropMatch = html.match(/
[\s\S]*?]*src=["']([^"']+)["']/i); // Parse Synopsis const synopsisMatch = html.match(/]*class=["']details-desc["'][^>]*>([\s\S]*?)<\/div>/i) || html.match(/]*class=["']entry-content[^"']*["'][^>]*>([\s\S]*?)<\/div>/i) || html.match(/

([\s\S]*?)<\/p>/i); const synopsis = synopsisMatch ? synopsisMatch[1].replace(/<[^>]+>/g, "").trim() : ""; // Parse Metadata const imdbMatch = html.match(/IMDb:\s*([\d.]+)/i); const qualityMatch = html.match(/]*class=["']data-quality["'][^>]*>([\s\S]*?)<\/span>/i); const genreMatch = html.match(/]*class=["']details-genre["'][^>]*>([\s\S]*?)<\/div>/i); const genres = genreMatch ? genreMatch[1].replace(/<[^>]+>/g, "").split(",").map(g => g.trim()) : []; // Parse Cast const cast = []; const castRegex = /class=["']zt-cast-name["']>([^<]+)<\/(?:span|div)>[\s\S]*?class=["']zt-cast-role["']>([^<]+)<\/(?:span|div)>/gi; let cm; while ((cm = castRegex.exec(html)) !== null) { cast.push({ name: cm[1].trim(), role: cm[2].trim() }); } // Parse Download Links (both zt-links and api- safe redirector) const dlRegex = /]*href=["'](https:\/\/cinesubz\.(?:net|lk)\/(?:zt-links|api-[^/"']+)\/[^"']+)["'][^>]*>([\s\S]*?)<\/a>/gi; const downloadLinks = []; let dm; while ((dm = dlRegex.exec(html)) !== null) { const linkUrl = dm[1]; const buttonBody = dm[2]; const metaMatch = buttonBody.match(/class=["']movie-download-meta["']>([^<]+)<\/span>/i); const rawLabel = metaMatch ? metaMatch[1].trim() : buttonBody.replace(/<[^>]+>/g, "").replace(/Direct & Telegram Download Links/g, "").trim(); // Parse Resolution, Size & Language from Label const parts = rawLabel.split("•").map(p => p.trim()); const quality = parts[0] || rawLabel; const size = parts[1] || null; const audio = parts[2] || null; downloadLinks.push({ label: rawLabel, quality, size, audio, zt_url: linkUrl }); } return { status: true, url, title, poster: posterMatch ? posterMatch[1] : null, backdrop: backdropMatch ? backdropMatch[1] : null, imdb_rating: imdbMatch ? imdbMatch[1] : null, quality: qualityMatch ? qualityMatch[1].trim() : null, genres, synopsis, cast: cast.slice(0, 10), download_links: downloadLinks }; } /** * Universal Scraper Dispatcher */ async function cinesubz(command, ...rest) { const clean = (command || "").trim(); if (!clean) throw new Error("Parameter input (query, URL movie, atau sub-command) wajib disertakan!"); const lower = clean.toLowerCase(); // Sub-command: search if (lower === "search") { const query = rest.join(" ").trim(); if (!query) throw new Error("Query pencarian tidak boleh kosong!"); return await search(query); } // Sub-command: detail if (lower === "detail") { const targetUrl = rest[0]; if (!targetUrl) throw new Error("URL detail movie tidak boleh kosong!"); return await getDetail(targetUrl); } // Sub-command: latest if (lower === "latest") { const type = (rest[0] === "tvshows" || rest[0] === "movies") ? rest[0] : "movies"; const page = rest[1] ? Number(rest[1]) : (!isNaN(Number(rest[0])) ? Number(rest[0]) : 1); return await getLatest(type, page); } // Sub-command: resolve if (lower === "resolve") { const ztUrl = rest[0]; if (!ztUrl) throw new Error("URL zt-link tidak boleh kosong!"); return await resolveZtLink(ztUrl); } // Direct zt-links URL if (clean.includes("/zt-links/")) { return await resolveZtLink(clean); } // Direct movie detail URL if (clean.startsWith("http://") || clean.startsWith("https://")) { const detail = await getDetail(clean); if (detail.download_links && detail.download_links.length > 0) { try { const first = detail.download_links[0]; const resolved = await resolveZtLink(first.zt_url); first.resolved_stream = resolved.direct_stream_url; } catch {} } return detail; } // Shorthand category if (clean === "movies" || clean === "tvshows") { return await getLatest(clean, rest[0] ? Number(rest[0]) : 1); } // Default: dianggap query pencarian return await search([clean, ...rest].join(" ").trim()); } // CommonJS safe export if (typeof module !== "undefined" && module.exports) { module.exports = { cinesubz, search, getLatest, getDetail, resolveZtLink }; } /** * CLI Runner: * Langsung eksekusi via terminal: * node cinesubz-movie-scraper.js search "Spider-Man" * node cinesubz-movie-scraper.js detail "https://cinesubz.net/movies/spider-man-brand-new-day-2026-sinhala-subtitles/" * node cinesubz-movie-scraper.js latest movies 1 * node cinesubz-movie-scraper.js resolve "https://cinesubz.net/zt-links/nvm2e3d9ep/" */ const cliArgs = process.argv.slice(2); const mainCommand = cliArgs[0] ? cliArgs[0].trim() : null; async function runCli() { if (!mainCommand) { console.log( JSON.stringify( { status: false, message: "Parameter sub-command belum ditentukan.", usage: { search: "node cinesubz-movie-scraper.js search ", detail: "node cinesubz-movie-scraper.js detail ", latest: "node cinesubz-movie-scraper.js latest [movies|tvshows] [page]", resolve: "node cinesubz-movie-scraper.js resolve " }, examples: [ "node cinesubz-movie-scraper.js search \"Spider-Man\"", "node cinesubz-movie-scraper.js detail \"https://cinesubz.net/movies/spider-man-brand-new-day-2026-sinhala-subtitles/\"", "node cinesubz-movie-scraper.js latest movies 1", "node cinesubz-movie-scraper.js resolve \"https://cinesubz.net/zt-links/nvm2e3d9ep/\"" ] }, null, 2 ) ); process.exit(1); } const res = await cinesubz(mainCommand, ...cliArgs.slice(1)); console.log(JSON.stringify(res, null, 2)); } if (process.argv[1]) { runCli().catch((err) => { console.error(JSON.stringify({ status: false, error: err.message }, null, 2)); process.exit(1); }); }