/** * ======================================================== * Name: UsersDrive File Data & Download Extractor * * Cara Download: * curl -sL "https://code.vamxapi.my.id/snippet/raw/usersdrive-downloader" -o usersdrive-downloader.js * * Cara Eksekusi: * node usersdrive-downloader.js "https://usersdrive.com/api/download-data/ce5wq9m88s4v.html" * node usersdrive-downloader.js "https://usersdrive.com/ce5wq9m88s4v.html" * * 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/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language": "en-US,en;q=0.9", }; /** * Extractor Utama UsersDrive * Mengurai ID file, nama file, kapasitas, tanggal upload, uploader, dan link download/tracker. */ async function extractUsersDrive(targetUrl) { const cleanUrl = (targetUrl || "").trim(); if (!cleanUrl) { throw new Error("URL UsersDrive wajib disertakan!"); } const fileIdMatch = cleanUrl.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>/i) || html.match(//i); const sizeMatch = html.match(/]*>([\s\S]*?)<\/span>/i); const dateMatch = html.match(/Uploaded on\s*([\s\S]*?)<\/b>\s*([\d:]+)/i); const uploaderMatch = html.match(/]+>/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: cleanUrl, }; } // Safe Export if (typeof module !== "undefined" && module.exports) { module.exports = { extractUsersDrive, default: extractUsersDrive, }; } // CLI Runner const cliArgs = process.argv.slice(2); const targetInput = cliArgs[0] ? cliArgs[0].trim() : null; async function runCli() { if (!targetInput) { console.log( JSON.stringify( { status: false, message: "Parameter URL UsersDrive belum disertakan.", usage: 'node usersdrive-downloader.js ""', examples: [ 'node usersdrive-downloader.js "https://usersdrive.com/api/download-data/ce5wq9m88s4v.html"', 'node usersdrive-downloader.js "https://usersdrive.com/ce5wq9m88s4v.html"', ], }, null, 2 ) ); process.exit(1); } const result = await extractUsersDrive(targetInput); 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); }); }