#!/usr/bin/env node /** * GMovie (com.gidev.gimovie) - Android API Scraper * Creator: SAURUS * Saluran: https://whatsapp.com/channel/0029VbDhTC6KLaHjHKXl552C * Note: pliss guys jangan di klaim 100% buatan lu, lu boleh kok modifikasi trs share lagi tapi tolong jangan ilangin header creator sama ch-nya */ import path from 'node:path'; import { fileURLToPath } from 'node:url'; const SAURUS_META = { Creator: 'SAURUS', Saluran: 'https://whatsapp.com/channel/0029VbDhTC6KLaHjHKXl552C' }; const CONFIG = { BASE_URL: 'https://app.ghie-lhanx.com/rest-api/v130', API_KEY: '24f9cf8494d424c', AUTHORIZATION: 'Basic Z2ltb3ZpZTpqfnNwdjI3b2c5a2U5enpr', USER_AGENT: 'okhttp/5.5.0', TIMEOUT_MS: 15000 }; async function requestApi(endpoint, params = {}) { const url = new URL(`${CONFIG.BASE_URL}/${endpoint.replace(/^\/+/, '')}`); for (const [k, v] of Object.entries(params)) { if (v !== undefined && v !== null && v !== '') { url.searchParams.set(k, String(v)); } } const controller = new AbortController(); const timer = setTimeout(() => controller.abort(), CONFIG.TIMEOUT_MS); try { const res = await fetch(url.toString(), { method: 'GET', headers: { 'API-KEY': CONFIG.API_KEY, 'Authorization': CONFIG.AUTHORIZATION, 'User-Agent': CONFIG.USER_AGENT, 'Accept-Encoding': 'gzip' }, signal: controller.signal }); const text = await res.text(); if (!res.ok) { throw new Error(`HTTP ${res.status}: ${text.slice(0, 300)}`); } return JSON.parse(text); } finally { clearTimeout(timer); } } async function getConfig() { return requestApi('config'); } async function getHome() { return requestApi('home_content_for_android'); } async function getMovies(page = 1) { return requestApi('movies', { page }); } async function getTvSeries(page = 1) { return requestApi('tvseries', { page }); } async function getDetails(id, type = 'movie') { return requestApi('single_details', { type, id }); } async function getComments(id) { return requestApi('all_comments', { id }); } async function search(q, type = 'movie', page = 1) { return requestApi('search', { q, type, page }); } function printSuccess(data) { console.log(JSON.stringify({ ...SAURUS_META, status: true, data }, null, 2)); } function printError(err) { console.error(JSON.stringify({ ...SAURUS_META, status: false, error: err instanceof Error ? err.message : String(err) }, null, 2)); process.exit(1); } async function main() { const args = process.argv.slice(2); const command = args[0]; if (!command || command === '--help' || command === '-h') { printSuccess({ description: 'GMovie (com.gidev.gimovie) Android API Scraper', usage: { config: 'node index.js config', home: 'node index.js home', movies: 'node index.js movies [--page 1]', tvseries: 'node index.js tvseries [--page 1]', details: 'node index.js details [--type movie|tvseries]', comments: 'node index.js comments ', search: 'node index.js search [--type movie|tvseries] [--page 1]' } }); return; } try { const getFlag = (name, fallback) => { const idx = args.indexOf(name); return idx !== -1 && args[idx + 1] ? args[idx + 1] : fallback; }; if (command === 'config') { printSuccess(await getConfig()); } else if (command === 'home') { printSuccess(await getHome()); } else if (command === 'movies') { printSuccess(await getMovies(Number(getFlag('--page', 1)))); } else if (command === 'tvseries') { printSuccess(await getTvSeries(Number(getFlag('--page', 1)))); } else if (command === 'details') { const id = args[1]; if (!id) throw new Error('Missing id argument'); printSuccess(await getDetails(id, getFlag('--type', 'movie'))); } else if (command === 'comments') { const id = args[1]; if (!id) throw new Error('Missing id argument'); printSuccess(await getComments(id)); } else if (command === 'search') { const q = args[1]; if (!q) throw new Error('Missing query argument'); printSuccess(await search(q, getFlag('--type', 'movie'), Number(getFlag('--page', 1)))); } else { throw new Error(`Unknown command: ${command}. Run with --help for usage.`); } } catch (err) { printError(err); } } const currentFile = fileURLToPath(import.meta.url); if (process.argv[1] && path.resolve(process.argv[1]) === path.resolve(currentFile)) { main(); } export { SAURUS_META, CONFIG, getConfig, getHome, getMovies, getTvSeries, getDetails, getComments, search }; export default { SAURUS_META, CONFIG, getConfig, getHome, getMovies, getTvSeries, getDetails, getComments, search };