import * as __ns_321 from 'axios' const axios = __ns_321.default import * as __ns_322 from 'node:url' const pathToFileURL = __ns_322.pathToFileURL async function reelsSearch(query, num = 10) { try { const cx = "e500c3a7a523b49df"; const ins = axios.create({ headers: { 'user-agent': 'Mozilla/5.0 (Linux; Android 16; SM-F966B Build) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Mobile Safari/537.36', 'x-client-data': 'CJDjygE=' } }); const { data: init } = await ins.get("https://cse.google.com/cse.js", { params: { cx: cx } }); const cfg_ = init.match(/}\)\(({[\s\S]*?})\);/); if (!cfg_ || !cfg_?.[1]) throw new Error("Failed to find config"); const cfg = JSON.parse(cfg_[1]); const params = { rsz: 'filtered_cse', num, hl: 'id', source: 'gcsc', cselibv: cfg.cselibVersion, cx: cx, q: query, safe: 'off', cse_tok: cfg.cse_token, lr: '', cr: '', gl: 'id', filter: 0, sort: '', as_oq: '', as_sitesearch: '', exp: 'cc,apo', oq: '', callback: 'google.search.cse.api11171', rurl: Buffer.from("aHR0cHM6Ly9yZWVsc2ZpbmRlci5zYXRpc2h5YWRhdi5jb20v", "base64").toString() }; let ab = await ins.get('https://cse.google.com/cse/element/v1', { params, }).then(response => response.data); const jsonStartIndex = ab.indexOf('{'); const jsonEndIndex = ab.lastIndexOf('}'); const jsonString = ab.slice(jsonStartIndex, jsonEndIndex + 1); const jsonData = JSON.parse(jsonString); return jsonData.results.map(item => ({ title: item.richSnippet?.metatags?.ogTitle || item.title, description: item.richSnippet?.metatags?.ogDescription || item.snippet, url: item.url, image: item.richSnippet?.metatags?.ogImage || (item.pagemap?.cse_image?.[0]?.src) })); } catch(e) { throw e; } } if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { const __exports = { reelsSearch: reelsSearch } const __fns = Object.fromEntries(Object.entries(__exports).filter(([, v]) => typeof v === 'function')) const __names = Object.keys(__fns) if (__names.length === 0) { console.log('Tidak ada fungsi yang bisa di-demo. Import modul ini dari kode lain.') } else { const __search = __names.find((n) => /search|cari/i.test(n)) const __name = __search || __names[0] const __fn = __fns[__name] const __isClass = /^class\s/.test(Function.prototype.toString.call(__fn)) const __defaultArgs = (() => { const n = __name.toLowerCase() if (/emoji/.test(n)) return [{ emoji: '😀😃' }] if (/textpro|generate.*text|effect/.test(n)) return ['neon', 'Hello'] if (/image|wallpaper|search|query|anime|movie|manga|news|lyrics|wiki|quote|stalk|detail/.test(n)) return ['naruto'] if (/download|youtube|video|audio|music|spotify|tiktok|instagram|facebook|twitter|reels|terabox|media/.test(n)) return ['https://www.youtube.com/watch?v=dQw4w9WgXcQ'] if (/dork/.test(n)) return ['example.com', 'documents'] if (/tts|speech|prompt|chat|ask|translate/.test(n)) return ['Hello world'] if (/parse|format|normalize|list|features/.test(n)) return [] return ['test'] })() let __args = __defaultArgs if (process.argv.length > 2) __args = process.argv.slice(2).map((a) => { try { return JSON.parse(a) } catch { return a } }) if (__args.length === 0 && !__search && !__isClass && __fn.length > 0) { console.log('Fungsi: ' + __names.join(', ')) console.log('Contoh: node ' + "reels-search.js" + ' ' + __name + ' ') } else { ;(async () => { try { const r = __isClass ? new __fn(...__args) : await __fn(...__args) console.log(JSON.stringify(r, null, 2)) } catch (e) { console.error('Error: ' + (e && e.message ? e.message : e)) process.exitCode = 1 } })() } } }