/** * ======================================================== * Name: SL Media Downloader & Stream Resolver (Zero CF & Safe/No 18) * * Multi-Platform Media Extractor & Stream Resolver: * 1. CineSubz (cinesubz.lk / cinesubz.net / zt-links / api redirector) * 2. SinhalaCHR Cloudflare Workers (sinhalachr.workers.dev) * 3. UsersDrive File Host (usersdrive.com) * * Cara Download: * curl -sL "https://code.vamxapi.my.id/snippet/raw/sl-media-downloader" -o sl-media-downloader.js * * Cara Eksekusi: * node sl-media-downloader.js "https://cinesubz.net/zt-links/nvm2e3d9ep/" * node sl-media-downloader.js "https://iws.sinhalachr.workers.dev/?id=HdaKhupc8mNuambr8F1UUvdQ&assetToken=V8iqjRWAxddTFaQD2DZ6qdZM" * node sl-media-downloader.js "https://usersdrive.com/api/download-data/ce5wq9m88s4v.html" * node sl-media-downloader.js search "Spider-Man" * * Author: Vamz Spectre * Source: https://vamxapi.my.id * ======================================================== */ 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,text/plain,*/*", "Accept-Language": "en-US,en;q=0.9", }; const CINESUBZ_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/" }, ]; /** * 1. Resolver CineSubz (Zero Cloudflare, Fast LiteSpeed Handshake) */ async function resolveCineSubz(targetUrl) { let url = targetUrl.trim().replace("cinesubz.lk", "cinesubz.net"); const res = await fetch(url, { headers: { ...DEFAULT_HEADERS, Referer: "https://cinesubz.net/", }, }); if (!res.ok) { throw new Error(`Link CineSubz gagal dibuka atau sudah kedaluwarsa (HTTP ${res.status}).`); } const html = await res.text(); const linkMatch = html.match(/]*id=["']link["'][^>]*href=["']([^"']+)["']/i); const titleMatch = html.match(/([^<]+)<\/title>/i); const prevLinkMatch = html.match(/<a[^>]*class=["']prev-lnk["'][^>]*href=["']([^"']+)["']/i); if (!linkMatch) { if (html.includes("Page not found") || html.includes("Please contact Admin")) { throw new Error("Link unduhan CineSubz sudah kedaluwarsa atau tidak valid di server."); } throw new Error("Elemen link unduhan tidak ditemukan di dalam halaman CineSubz."); } const originalUrl = linkMatch[1]; let finalStreamUrl = originalUrl; for (const mapping of CINESUBZ_URL_MAPPINGS) { let matched = false; for (const searchUrl of mapping.search) { if (finalStreamUrl.includes(searchUrl)) { finalStreamUrl = finalStreamUrl.replace(searchUrl, mapping.replace); if (finalStreamUrl.includes(".mp4?bot=cscloud2bot&code=")) { finalStreamUrl = finalStreamUrl.replace(".mp4?bot=cscloud2bot&code=", "?ext=mp4&bot=cscloud2bot&code="); } else if (finalStreamUrl.includes(".mp4")) { finalStreamUrl = finalStreamUrl.replace(".mp4", "?ext=mp4"); } else if (finalStreamUrl.includes(".mkv?bot=cscloud2bot&code=")) { finalStreamUrl = finalStreamUrl.replace(".mkv?bot=cscloud2bot&code=", "?ext=mkv&bot=cscloud2bot&code="); } else if (finalStreamUrl.includes(".mkv")) { finalStreamUrl = finalStreamUrl.replace(".mkv", "?ext=mkv"); } else if (finalStreamUrl.includes(".zip")) { finalStreamUrl = finalStreamUrl.replace(".zip", "?ext=zip"); } matched = true; break; } } if (matched) break; } const isTelegram = originalUrl.includes("t.me") || originalUrl.includes("srilanka2222"); return { status: true, platform: "CineSubz", type: isTelegram ? "telegram_channel" : "direct_video_stream", title: titleMatch ? titleMatch[1].replace(/–/g, "-").replace(/’/g, "'").trim() : "CineSubz Media", movie_page: prevLinkMatch ? prevLinkMatch[1] : null, target_url: targetUrl, original_url: originalUrl, direct_stream_url: finalStreamUrl, is_telegram: isTelegram, }; } /** * 2. Extractor SinhalaCHR Cloudflare Worker Media */ async function resolveSinhalaCHR(targetUrl) { const url = targetUrl.trim(); const res = await fetch(url, { headers: DEFAULT_HEADERS, }); if (!res.ok) { throw new Error(`Gagal mengakses SinhalaCHR Worker: HTTP ${res.status}`); } const html = await res.text(); const titleMatch = html.match(/<strong>Title:<\/strong>\s*([^<]+)<\/p>/i); const sizeMatch = html.match(/<strong>Size:<\/strong>\s*([^<]+)<\/p>/i); const resMatch = html.match(/<strong>Resolution:<\/strong>\s*([^<]+)<\/p>/i); const videoSourceMatch = html.match(/<source\s+src=["']([^"']+)["']/i); const telegramMatch = html.match(/<a\s+href=["'](https:\/\/t\.me\/[^"']+)["']/i); const parsedUrl = new URL(url); const id = parsedUrl.searchParams.get("id"); const assetToken = parsedUrl.searchParams.get("assetToken"); const downloadUrl = id && assetToken ? `${parsedUrl.origin}/?id=${encodeURIComponent(id)}&assetToken=${encodeURIComponent(assetToken)}&download=true` : null; const streamUrl = videoSourceMatch ? videoSourceMatch[1] : null; return { status: true, platform: "SinhalaCHR Workers", type: "direct_video_stream", title: titleMatch ? titleMatch[1].trim() : "SinhalaCHR Media", size: sizeMatch ? sizeMatch[1].trim() : null, resolution: resMatch ? resMatch[1].trim() : null, direct_stream_url: streamUrl, direct_download_url: downloadUrl, telegram_channel: telegramMatch ? telegramMatch[1] : "https://t.me/sinhalaaaa", source_url: targetUrl, }; } /** * 3. Extractor UsersDrive File Hosting (Zero CF) */ async function resolveUsersDrive(targetUrl) { const url = targetUrl.trim(); const fileIdMatch = url.match(/\/([a-zA-Z0-9]+)(?:\.html)?(?:$|[?#])/); if (!fileIdMatch || !fileIdMatch[1]) { throw new Error("Gagal membaca File ID dari link UsersDrive."); } const fileId = fileIdMatch[1]; const standardPageUrl = `https://usersdrive.com/${fileId}.html`; const res = await fetch(standardPageUrl, { headers: DEFAULT_HEADERS, }); if (!res.ok) { throw new Error(`Gagal membuka link UsersDrive: HTTP ${res.status}`); } const html = await res.text(); if (html.includes("File Not Found") || html.includes("deleted by the owner")) { throw new Error("File di UsersDrive tidak ditemukan atau sudah dihapus oleh uploader."); } const nameMatch = html.match(/<h4>([^<]+)<\/h4>/i) || html.match(/<meta name="description" content="Download File ([^"]+)">/i); const sizeMatch = html.match(/<span class="size"[^>]*>([\s\S]*?)<\/span>/i); const dateMatch = html.match(/Uploaded on\s*<b>([\s\S]*?)<\/b>\s*([\d:]+)/i); const uploaderMatch = html.match(/<a href="https:\/\/usersdrive\.com\/users\/([^"]+)"/i); const rawBytesMatch = html.match(/\[URL=https:\/\/usersdrive\.com\/[^\]]+\][^<]*-\s*(\d+)\[\/URL\]/i); return { status: true, platform: "UsersDrive", type: "file_download_page", file_id: fileId, title: nameMatch ? nameMatch[1].trim() : `UsersDrive_${fileId}`, size: sizeMatch ? sizeMatch[1].replace(/<[^>]+>/g, "").trim() : null, size_bytes: rawBytesMatch ? Number(rawBytesMatch[1]) : null, upload_date: dateMatch ? `${dateMatch[1].trim()} ${dateMatch[2].trim()}` : null, uploader: uploaderMatch ? uploaderMatch[1].trim() : null, page_url: standardPageUrl, tracker_torrent_url: `https://usersdrive.com/cgi-bin/tracker.cgi?file_code=${fileId}`, source_url: targetUrl, }; } /** * 4. Search CineSubz Catalog (Safe Mode / Exclude 18+ Genre) */ async function searchCineSubz(query) { const cleanQ = (query || "").trim(); if (!cleanQ) throw new Error("Query pencarian tidak boleh kosong!"); const searchUrl = `https://cinesubz.net/wp-json/zetaflix/search/?keyword=${encodeURIComponent(cleanQ)}&nonce=11c13d6e10`; const res = await fetch(searchUrl, { headers: DEFAULT_HEADERS }); if (!res.ok) throw new Error(`Pencarian CineSubz 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 out 18+ content strictly .filter((item) => !item.is_adult); return { status: true, platform: "CineSubz", query: cleanQ, total: results.length, results, }; } /** * Universal Dispatcher: Auto-detects platform URL */ async function resolve(target) { const input = (target || "").trim(); if (!input) { throw new Error("Parameter URL atau query wajib disertakan!"); } // 1. SinhalaCHR Workers if (input.includes("sinhalachr.workers.dev")) { return await resolveSinhalaCHR(input); } // 2. UsersDrive if (input.includes("usersdrive.com")) { return await resolveUsersDrive(input); } // 3. CineSubz if (input.includes("cinesubz.lk") || input.includes("cinesubz.net") || input.includes("zt-links") || input.includes("api-")) { return await resolveCineSubz(input); } // Fallback: search CineSubz return await searchCineSubz(input); } // Safe Export if (typeof module !== "undefined" && module.exports) { module.exports = { resolve, resolveCineSubz, resolveSinhalaCHR, resolveUsersDrive, searchCineSubz, default: resolve, }; } // CLI Runner 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 URL atau query belum disertakan.", usage: { universal: "node sl-media-downloader.js <url_or_query>", search: "node sl-media-downloader.js search <movie_name>", cinesubz: "node sl-media-downloader.js cinesubz <url_cinesubz>", sinhalachr: "node sl-media-downloader.js sinhalachr <url_sinhalachr>", usersdrive: "node sl-media-downloader.js usersdrive <url_usersdrive>", }, examples: [ 'node sl-media-downloader.js "https://cinesubz.net/zt-links/nvm2e3d9ep/"', 'node sl-media-downloader.js "https://iws.sinhalachr.workers.dev/?id=HdaKhupc8mNuambr8F1UUvdQ&assetToken=V8iqjRWAxddTFaQD2DZ6qdZM"', 'node sl-media-downloader.js "https://usersdrive.com/api/download-data/ce5wq9m88s4v.html"', 'node sl-media-downloader.js search "Spider-Man"', ], }, null, 2 ) ); process.exit(1); } let result; if (mainCommand === "search" && cliArgs[1]) { result = await searchCineSubz(cliArgs.slice(1).join(" ")); } else if (mainCommand === "cinesubz" && cliArgs[1]) { result = await resolveCineSubz(cliArgs[1]); } else if (mainCommand === "sinhalachr" && cliArgs[1]) { result = await resolveSinhalaCHR(cliArgs[1]); } else if (mainCommand === "usersdrive" && cliArgs[1]) { result = await resolveUsersDrive(cliArgs[1]); } else { result = await resolve(mainCommand); } console.log(JSON.stringify(result, null, 2)); } if (process.argv[1]) { runCli().catch((err) => { console.error(JSON.stringify({ status: false, error: err.message || String(err) }, null, 2)); process.exit(1); }); }