/** * APK Downloader & Google Play Metadata Scraper * * Features: * - Scrapes Google Play Store app metadata & reviews * - Resolves direct CDN APK download links with MD5 hash & file size * - Supports Google Play URLs, direct Package IDs, or app search terms * - Anti-virus & malware verification status check * - Zero extra runtime dependencies (pure Node.js 18+ with optional Cheerio support) * * Download & Run: * curl -sL "https://code.vamxapi.my.id/snippet/raw/apk-downloader" -o apk-downloader.js * node apk-downloader.js "https://play.google.com/store/apps/details?id=my.com.tngdigital.ewallet" * node apk-downloader.js "my.com.tngdigital.ewallet" * * Author: Vamz Spectre / VamxAPI */ let cheerio; try { cheerio = require("cheerio"); } catch { // Optional dependency, regex parser fallback included } /** * Format bytes into readable string * @param {number} bytes * @returns {string} */ function formatBytes(bytes) { if (!bytes || isNaN(bytes)) return "0 B"; const k = 1024; const sizes = ["B", "KB", "MB", "GB", "TB"]; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i]; } /** * Clean installs count string * @param {string} raw * @returns {string} */ function cleanInstalls(raw) { if (!raw) return null; return raw.replace(/^[0-9.,]+\s*star/i, "").trim() || raw.trim(); } /** * Scrape Play Store HTML metadata * @param {string} packageId * @returns {Promise} */ async function scrapePlayStore(packageId) { try { const playUrl = `https://play.google.com/store/apps/details?id=${encodeURIComponent(packageId)}&hl=id&gl=ID`; const res = await fetch(playUrl, { 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-Language": "id-ID,id;q=0.9,en;q=0.8" } }); if (!res.ok) return null; const html = await res.text(); if (cheerio) { const $ = cheerio.load(html); const title = $("h1").first().text().trim() || null; const developer = $("a[href*=\"/store/apps/developer?id=\"]").first().text().trim() || $("a[href*=\"/store/apps/dev?id=\"]").first().text().trim() || null; let rating = ($("[itemprop=\"starRating\"]").text().trim() || $("div.j2ttFe").text().trim() || ""); rating = rating.replace(/star/i, "").replace(",", ".").trim() || null; const reviews = $("div.EHZ5gh").text().trim() || $("div.g1rdde:contains(\"ulasan\")").text().trim() || null; const installs = cleanInstalls($("div.ClM7O").text().trim()); const description = $("div[data-g-id=\"description\"]").text().trim() || $(".bARER").text().trim() || null; let icon = $("img[alt*=\"icon\" i]").attr("src") || $("img[alt=\"Ikon gambar\"]").attr("src") || null; if (icon && icon.startsWith("//")) icon = "https:" + icon; return { title, developer, rating, reviews, installs, description, icon }; } // Pure regex fallback const titleMatch = html.match(/]*>[\s\S]*?]*itemprop="name"[^>]*>([^<]+)<\/span>/i) || html.match(/]*>([^<]+)<\/h1>/i); const title = titleMatch ? titleMatch[1].trim() : null; const devMatch = html.match(/\/store\/apps\/developer\?id=[^"]*"[^>]*>([^<]+)<\/a>/i) || html.match(/\/store\/apps\/dev\?id=[^"]*"[^>]*>([^<]+)<\/a>/i); const developer = devMatch ? devMatch[1].trim() : null; const ratingMatch = html.match(/itemprop="starRating"[^>]*>.*?([0-9.,]+)\s*star/is) || html.match(/class="j2ttFe"[^>]*>([0-9.,]+)/i); const rating = ratingMatch ? ratingMatch[1].replace(",", ".").trim() : null; const iconMatch = html.match(/src="(https:\/\/play-lh\.googleusercontent\.com\/[^"]+)"/i); const icon = iconMatch ? iconMatch[1] : null; return { title, developer, rating, reviews: null, installs: null, description: null, icon }; } catch { return null; } } /** * APK Downloader and App Metadata Scraper * @param {string} input - Google Play Store URL, package name, or search query * @returns {Promise} */ async function apkDownloader(input) { if (!input || typeof input !== "string" || !input.trim()) { throw new Error("Parameter input (Google Play URL / Package Name / Keyword) wajib disertakan."); } const cleanInput = input.trim(); let packageId = ""; // 1. Google Play Store URL if (cleanInput.includes("play.google.com/store/apps/details")) { const match = cleanInput.match(/[?&]id=([a-zA-Z0-9_.]+)/); if (match) packageId = match[1]; } else if (/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(cleanInput)) { // 2. Direct Package ID (e.g. my.com.tngdigital.ewallet) packageId = cleanInput; } else { // 3. Search query const searchUrl = `https://ws75.aptoide.com/api/7/apps/search/query=${encodeURIComponent(cleanInput)}/limit=1`; const searchRes = await fetch(searchUrl); const searchData = await searchRes.json(); if (searchData.datalist?.list && searchData.datalist.list.length > 0) { packageId = searchData.datalist.list[0].package; } else { throw new Error(`Aplikasi dengan kata kunci "${cleanInput}" tidak ditemukan.`); } } if (!packageId) { throw new Error("Gagal mengidentifikasi Package ID dari parameter yang diberikan."); } // Fetch APK binary details from CDN repository const cdnUrl = `https://ws75.aptoide.com/api/7/app/get/package_name=${encodeURIComponent(packageId)}`; const cdnRes = await fetch(cdnUrl); const cdnData = await cdnRes.json(); const meta = cdnData?.nodes?.meta?.data; if (!meta || !meta.file?.path) { throw new Error(`Berkas APK untuk package "${packageId}" tidak tersedia untuk diunduh.`); } // Scrape Play Store metadata concurrently const playMeta = await scrapePlayStore(packageId); // Versions history const versionsList = (cdnData.nodes?.versions?.list || []).slice(0, 5).map(v => ({ version: v.file?.vername || null, versionCode: v.file?.vercode || null, size: formatBytes(v.file?.filesize || v.size), sizeBytes: v.file?.filesize || v.size, md5: v.file?.md5sum || null, updatedAt: v.updated || v.modified || null })); return { status: true, creator: "Vamz Spectre", data: { name: playMeta?.title || meta.name, package: meta.package, version: meta.file?.vername || null, versionCode: meta.file?.vercode || null, size: formatBytes(meta.file?.filesize || meta.size), sizeBytes: meta.file?.filesize || meta.size, updatedAt: meta.modified || meta.updated || null, developer: { name: playMeta?.developer || meta.developer?.name || null, website: meta.developer?.website || null, email: meta.developer?.email || null }, stats: { rating: playMeta?.rating || (meta.stats?.rating?.avg ? meta.stats.rating.avg.toFixed(1) : null), reviews: playMeta?.reviews || null, installs: playMeta?.installs || (meta.stats?.downloads ? `${meta.stats.downloads.toLocaleString()}+` : null) }, icon: playMeta?.icon || meta.icon || null, graphic: meta.graphic || null, download: { url: meta.file?.path, altUrl: meta.file?.path_alt || null, md5: meta.file?.md5sum || null, minSdk: meta.file?.hardware?.sdk || null, supportedCpu: meta.file?.hardware?.cpus || [], securityStatus: meta.file?.malware?.rank || "UNKNOWN", sha1: meta.file?.signature?.sha1 || null }, description: playMeta?.description || null, screenshots: meta.media?.screenshots?.map(s => s.url) || [], versions: versionsList } }; } // Module Export module.exports = { apkDownloader, scrapePlayStore }; // 1:1 CLI Runner if (require.main === module) { const target = process.argv[2] || "https://play.google.com/store/apps/details?id=my.com.tngdigital.ewallet"; apkDownloader(target) .then(res => console.log(JSON.stringify(res, null, 2))) .catch(err => { console.error(JSON.stringify({ status: false, error: err.message }, null, 2)); process.exit(1); }); }