downloaderjavascript6519
9xbuddy AIO Multi-Platform Media Downloader Engine
Scraper All-In-One dengan custom base64 cipher reverse-engineering. Mendukung YouTube, TikTok, Facebook, Instagram, Twitter/X, SoundCloud, Vimeo, dan puluhan platform lainnya.
Vamz Spectre29 Sep 2026410 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/aio-multi-downloader" -o aio-multi-downloader.js
# 2. Jalankan script
node aio-multi-downloader.js
Dependencies npm yang Dibutuhkan:
npm install axios cheerioPanduan Penggunaan:
// Instalasi: npm install axios cheerio // Penggunaan CLI: node aio-multi-downloader.js "https://www.tiktok.com/@tiktok/video/7106594312292453675"
aio-multi-downloader.js(410 lines)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
/**
* 9xbuddy AIO (All-in-One) Downloader Scraper with Vamx CDN Integration
* Author: Vamz Spectre
* Base Engine: 9xbuddy.site reverse engineered
* Supported Platforms: YouTube, TikTok, Twitter/X, Instagram, Facebook, SoundCloud, Reddit, Vimeo, dll.
*
* Cara pakai:
* node aio-scraper.js "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
* node aio-scraper.js "https://www.tiktok.com/@tiktok/video/7106594312292453675"
*/
const dns = require("dns");
// Pastikan prioritas IPv4
try {
dns.setDefaultResultOrder('ipv4first');
} catch {}
// 1. Custom Cipher Engine
class Cipher {
ord(e) {
const t = `${e}`;
const n = t.charCodeAt(0);
if (n >= 55296 && n <= 56319) {
if (t.length === 1) return n;
const r = t.charCodeAt(1);
return (n - 55296) * 1024 + (r - 56320) + 65536;
}
return n;
}
encode64(e) {
if (/([^\u0000-\u00ff])/.test(e)) throw Error("Can't base64 encode non-ASCII characters.");
const t = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
let n = 0, r, i, a, o = [];
while (n < e.length) {
r = e.charCodeAt(n);
a = n % 3;
switch (a) {
case 0: o.push(t.charAt(r >> 2)); break;
case 1: o.push(t.charAt(((i & 3) << 4) | (r >> 4))); break;
case 2: o.push(t.charAt(((i & 15) << 2) | (r >> 6))); o.push(t.charAt(r & 63)); break;
}
i = r;
n++;
}
if (a === 0) {
o.push(t.charAt((i & 3) << 4));
o.push('==');
} else if (a === 1) {
o.push(t.charAt((i & 15) << 2));
o.push('=');
}
return o.join('');
}
decode64(e) {
if (!e) return '';
e = e.replace(/\s/g, '');
if (!/^[a-z0-9\+\/\s]+\={0,2}$/i.test(e) || e.length % 4 > 0) return '';
let t = 0, n, r, i, a = [];
e = e.replace(/=/g, '');
while (t < e.length) {
n = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.indexOf(e.charAt(t));
i = t % 4;
switch (i) {
case 1: a.push(String.fromCharCode((r << 2) | (n >> 4))); break;
case 2: a.push(String.fromCharCode(((r & 15) << 4) | (n >> 2))); break;
case 3: a.push(String.fromCharCode(((r & 3) << 6) | n)); break;
}
r = n;
t++;
}
return a.join('');
}
encrypt(e, t) {
let n = '';
for (let r = 0; r < e.length; r++) {
const i = e.substr(r, 1);
const a = t.substr((r % t.length) - 1, 1);
const sum = Math.floor(this.ord(i) + this.ord(a));
n += String.fromCharCode(sum);
}
return this.encode64(n);
}
decrypt(e, t) {
let n = '';
const decoded = this.decode64(e);
if (!decoded) return null;
for (let r = 0; r < decoded.length; r++) {
const i = decoded.substr(r, 1);
const a = t.substr((r % t.length) - 1, 1);
const diff = Math.floor(this.ord(i) - this.ord(a));
n += String.fromCharCode(diff);
}
return n;
}
hex2bin(e) {
const t = [];
let n = 0;
e += '';
for (const r = e.length; n < r; n += 2) {
const hi = parseInt(e.substr(n, 1), 16);
const lo = parseInt(e.substr(n + 1, 1), 16);
if (isNaN(hi) || isNaN(lo)) return false;
t.push((hi << 4) | lo);
}
return String.fromCharCode(...t);
}
}
const cipher = new Cipher();
// 2. Fungsi Upload Langsung ke Vamx CDN
async function uploadToVamxCdn(fileUrl, filename = 'media.mp4') {
if (!fileUrl || !fileUrl.startsWith('http')) return fileUrl;
try {
const res = await fetch(fileUrl, {
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)',
},
});
if (!res.ok) return fileUrl;
const arrayBuffer = await res.arrayBuffer();
const contentType = res.headers.get('content-type') || 'application/octet-stream';
const blob = new Blob([arrayBuffer], { type: contentType });
const form = new FormData();
form.append('file', blob, filename);
const uploadRes = await fetch('https://cdn.vamxapi.my.id/api/v1/media/upload', {
method: 'POST',
headers: {
'x-client-mode': 'vamx-cdn',
},
body: form,
});
const json = await uploadRes.json();
if (json.status && json.result?.media?.url) {
return json.result.media.url;
}
} catch (err) {
// Fallback URL jika upload CDN gagal
}
return fileUrl;
}
// 3. Generate Auth Token
function generateAuthToken(html, windowInit, hostname = '9xbuddy.site') {
const cssMatch = /\/build\/(?:assets\/)?main\.([^"]+?)\.css/g.exec(html);
const cssHash = cssMatch ? cssMatch[1] : '';
const i = cssHash.split('').reverse().join('');
const a = (windowInit.ua || '').split('').reverse().join('').substr(0, 10);
const o = [90, 84, 94, 100, 81, 81, 74, 89, 100, 70, 83, 83, 84, 76, 100, 89, 84, 83, 100, 82, 78, 100, 74, 89, 70, 82, 100, 94, 87, 87, 84, 88]
.map((e) => String.fromCharCode(e - 5))
.reverse()
.join('');
const s = windowInit.appVersion || '12.18.8';
const c = `xbuddy123sudo-${s}`;
const l = hostname + i + a + o + c + s;
const authToken = cipher.encrypt(l, i);
return { authToken, cssHash };
}
// 4. Dekripsi Format URL
function decodeFormatUrl(encodedHex, token, cssHash, hostname = '9xbuddy.site') {
const bin = cipher.hex2bin(encodedHex);
if (!bin) return encodedHex;
const o = bin.split('').reverse().join('');
const prefix = [69, 84, 65, 77, 95, 89, 82, 82, 79, 83]
.map((e) => String.fromCharCode(e))
.join('')
.split('')
.reverse()
.join('');
const s = `${prefix}${hostname.length}${cssHash}${token}`;
const decrypted = cipher.decrypt(o, s);
return decrypted || encodedHex;
}
// 5. Resolve Download URL
async function resolveDownloadUrl(apiBase, authToken, accessToken, downloadPath) {
const match = /\/download\/([^\/]+)\/([^\/\?]+)/.exec(downloadPath);
if (!match) return downloadPath;
const uid = match[1];
const urlParam = match[2];
try {
const dlRes = await fetch(`${apiBase}/download`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
'X-Requested-With': 'xmlhttprequest',
'x-auth-token': authToken,
'x-requested-domain': '9xbuddy.site',
'x-access-token': accessToken,
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
Origin: 'https://9xbuddy.site',
Referer: 'https://9xbuddy.site/',
},
body: JSON.stringify({ uid, url: urlParam, mode: 'inspect' }),
});
const dlData = await dlRes.json().catch(() => ({}));
if (dlData.url) return dlData.url;
const streamFallback = dlData.video_edit?.formats?.url;
const activeUid = dlData.uid || uid;
for (let i = 0; i < 4; i++) {
await new Promise((r) => setTimeout(r, 800));
const progRes = await fetch(`${apiBase}/progress`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
'X-Requested-With': 'xmlhttprequest',
'x-auth-token': authToken,
'x-requested-domain': '9xbuddy.site',
'x-access-token': accessToken,
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
Origin: 'https://9xbuddy.site',
Referer: 'https://9xbuddy.site/',
},
body: JSON.stringify({ uid: activeUid }),
});
const progData = await progRes.json().catch(() => ({}));
if (progData.response?.url) {
return progData.response.url;
}
}
if (streamFallback) {
return streamFallback.startsWith('//') ? `https:${streamFallback}` : streamFallback;
}
} catch {}
return `https://9xbuddy.site${downloadPath}`;
}
// 6. Fungsi Scraper AIO + Auto Simpan Vamx CDN
async function scrapeAIO(targetUrl, options = { saveToCdn: true }) {
const cleanUrl = targetUrl.trim();
// Step 1: Inisialisasi token
const pageRes = await fetch('https://9xbuddy.site/id', {
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
},
});
if (!pageRes.ok) throw new Error(`HTTP Error ${pageRes.status}`);
const html = await pageRes.text();
const start = html.indexOf('window.__INIT__ = ');
if (start === -1) throw new Error('window.__INIT__ tidak ditemukan.');
const end = html.indexOf('</script>', start);
let jsonStr = html.slice(start + 'window.__INIT__ = '.length, end).trim();
if (jsonStr.endsWith(';')) jsonStr = jsonStr.slice(0, -1);
const windowInit = JSON.parse(jsonStr);
const { authToken, cssHash } = generateAuthToken(html, windowInit, '9xbuddy.site');
const apiBase = windowInit.apiBase || 'https://ab.9xbud.com';
// Step 2: Ambil access token
const tokenRes = await fetch(`${apiBase}/token`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
'X-Requested-With': 'xmlhttprequest',
'x-auth-token': authToken,
'x-requested-domain': '9xbuddy.site',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
Origin: 'https://9xbuddy.site',
Referer: 'https://9xbuddy.site/',
},
body: JSON.stringify({}),
});
const tokenData = await tokenRes.json().catch(() => ({}));
if (!tokenData.status || !tokenData.access_token) {
throw new Error('Gagal mendapatkan token autentikasi.');
}
const accessToken = tokenData.access_token;
// Step 3: Ekstraksi Media
const encodedUrl = encodeURIComponent(cleanUrl);
const sig = cipher.encrypt(encodedUrl, `${authToken}jv7g2_DAMNN_DUDE`);
const extractRes = await fetch(`${apiBase}/extract`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
'X-Requested-With': 'xmlhttprequest',
'x-auth-token': authToken,
'x-requested-domain': '9xbuddy.site',
'x-access-token': accessToken,
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
Origin: 'https://9xbuddy.site',
Referer: 'https://9xbuddy.site/',
},
body: JSON.stringify({ url: encodedUrl, _sig: sig }),
});
const extractData = await extractRes.json().catch(() => ({}));
if (!extractData || extractData.status === false || !extractData.response) {
throw new Error(extractData?.message || 'Gagal mengekstrak media.');
}
const resp = extractData.response;
const rawFormats = Array.isArray(resp.formats) ? resp.formats : [];
const token = resp.token || accessToken;
// Step 4: Dekripsi format
const formats = [];
for (const fmt of rawFormats) {
if (!fmt.url) continue;
let decodedUrl = decodeFormatUrl(fmt.url, token, cssHash);
if (!decodedUrl) continue;
// Filter iklan & tracker
if (
decodedUrl.includes('offmp3.com') ||
decodedUrl.includes('savegif.com') ||
decodedUrl.includes('criteo.com') ||
decodedUrl.includes('secure.soundcloud.com')
) {
continue;
}
if (decodedUrl.startsWith('//')) {
decodedUrl = `https:${decodedUrl}`;
}
formats.push({
quality: String(fmt.quality || 'Default').trim(),
type: fmt.type || 'video',
ext: String(fmt.ext || 'mp4').toLowerCase(),
size: fmt.size && fmt.size !== '-' ? fmt.size : undefined,
url: decodedUrl,
});
}
// Step 5: Resolve format terbaik
const bestFormat = formats.find((f) => f.quality.includes('720p')) || formats.find((f) => f.type === 'video') || formats[0];
if (bestFormat && bestFormat.url.startsWith('/download/')) {
bestFormat.url = await resolveDownloadUrl(apiBase, authToken, accessToken, bestFormat.url);
}
let thumbnail = resp.thumbnail;
if (thumbnail && thumbnail.startsWith('//')) thumbnail = `https:${thumbnail}`;
let mediaUrl = bestFormat?.url;
// Step 6: Upload ke Vamx CDN jika opsi saveToCdn aktif
if (options.saveToCdn !== false) {
// 1. Upload Thumbnail
if (thumbnail && thumbnail.startsWith('http')) {
thumbnail = await uploadToVamxCdn(thumbnail, `thumb_${Date.now()}.webp`);
}
// 2. Upload Video/Media Utama
if (mediaUrl && mediaUrl.startsWith('http')) {
const ext = bestFormat?.ext || 'mp4';
const cdnUrl = await uploadToVamxCdn(mediaUrl, `media_${Date.now()}.${ext}`);
if (cdnUrl !== mediaUrl) {
mediaUrl = cdnUrl;
if (bestFormat) bestFormat.url = cdnUrl;
}
}
}
return {
title: resp.title || 'Media',
duration: resp.duration || (resp.duration_raw ? `${resp.duration_raw}s` : undefined),
uploader: resp.uploader && resp.uploader !== 'Unknown' ? resp.uploader : undefined,
thumbnail,
media: mediaUrl,
type: resp.type || 'video',
formats,
};
}
// CLI Runner
if (process.argv[2]) {
const url = process.argv[2];
console.log(`Mengunduh dan menyimpan ke Vamx CDN untuk: ${url} ...\n`);
scrapeAIO(url, { saveToCdn: true })
.then((result) => {
console.log(JSON.stringify(result, null, 2));
})
.catch((err) => {
console.error('Error:', err.message);
process.exit(1);
});
}
if (typeof module !== "undefined" && module.exports) {
module.exports = { scrapeAIO, default: scrapeAIO };
}