downloaderjavascript24264
YTTMP3 - YouTube Video to MP3 Audio Converter Engine
Engine konversi audio YouTube ke MP3 instan berkecepatan tinggi dengan auto polling status konversi dan link download langsung.
Vamz Spectre29 Sep 2026408 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/yttmp3-converter" -o yttmp3-converter.js
# 2. Jalankan script
node yttmp3-converter.js
Dependencies npm yang Dibutuhkan:
npm install axiosPanduan Penggunaan:
// Instalasi: npm install axios // Penggunaan: node yttmp3-converter.js "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
yttmp3-converter.js(408 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
/**
* YTMP3 (yttmp3.com.co) YouTube to MP3 & MP4 Converter / Downloader Scraper
* Author: Vamz Spectre (Vamx)
* Target: yttmp3.com.co (Engine: savetube.vip reverse engineered)
* Decryption: AES-128-CBC (Seed Key: C5D58EF67A7584E4A29F6C35BBC4EB12)
*
* Fitur:
* - Direct MP3 audio converter (up to 320kbps)
* - Direct MP4 video converter (360p, 480p, 720p, 1080p, 1440p, 2160p)
* - Ekstraksi metadata video (title, duration, thumbnail, formats list)
* - Dukungan Vamx CDN upload (opsional)
* - Output format JSON murni & production-ready untuk Bot WA / Telegram / REST API
*
* Penggunaan CLI:
* node yttmp3.js "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
* node yttmp3.js mp3 "https://youtu.be/kJQP7kiw5Fk"
* node yttmp3.js mp4 "https://youtu.be/kJQP7kiw5Fk" 720
* node yttmp3.js info "https://youtu.be/kJQP7kiw5Fk"
*/
const crypto = require("crypto");
const axios = require("axios");
// AES-128-CBC Decryption Key dari bundle Next.js yttmp3.com.co
const AES_KEY = Buffer.from("C5D58EF67A7584E4A29F6C35BBC4EB12", "hex");
const DEFAULT_HEADERS = {
"Content-Type": "application/json",
Origin: "https://yttmp3.com.co",
Referer: "https://yttmp3.com.co/",
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
};
/**
* 1. Mendapatkan CDN server acak dari savetube
*/
async function getRandomCdn() {
try {
const res = await axios.get("https://media.savetube.vip/api/random-cdn", {
headers: DEFAULT_HEADERS,
timeout: 10000,
});
if (res.data && res.data.cdn) {
return res.data.cdn;
}
return "cdn401.savetube.vip";
} catch {
return "cdn401.savetube.vip";
}
}
/**
* 2. Dekripsi payload AES-128-CBC dari endpoint /v2/info
*/
function decryptPayload(base64Data) {
try {
const rawBuffer = Buffer.from(base64Data.replace(/\s/g, ""), "base64");
if (rawBuffer.length < 16) {
throw new Error("Invalid payload: buffer length less than 16 bytes");
}
const iv = rawBuffer.subarray(0, 16);
const ciphertext = rawBuffer.subarray(16);
const decipher = crypto.createDecipheriv("aes-128-cbc", AES_KEY, iv);
let decrypted = decipher.update(ciphertext);
decrypted = Buffer.concat([decrypted, decipher.final()]);
return JSON.parse(decrypted.toString("utf8"));
} catch (err) {
throw new Error(`Gagal mendekripsi payload YTMP3: ${err.message}`);
}
}
/**
* 3. Ambil metadata dan format video dari YouTube URL
*/
async function getVideoInfo(youtubeUrl, cdnHost = null) {
if (!youtubeUrl || typeof youtubeUrl !== "string") {
throw new Error("YouTube URL diperlukan");
}
const cdn = cdnHost || (await getRandomCdn());
const res = await axios.post(
`https://${cdn}/v2/info`,
{ url: youtubeUrl.trim() },
{ headers: DEFAULT_HEADERS, timeout: 20000 }
);
const body = res.data;
if (!body || body.status === false || !body.data) {
throw new Error(body?.message || "Gagal mengambil data video dari YTMP3");
}
const videoData = decryptPayload(body.data);
return {
cdn,
data: videoData,
};
}
/**
* 4. Generate URL Download (Audio MP3 atau Video MP4)
*/
async function getDownloadUrl({ key, titleSlug = "", quality = "128", type = "audio", directUrl = null, cdnHost = null }) {
const cdn = cdnHost || (await getRandomCdn());
// Jika format video langsung tersedia dari googlevideo
if (directUrl && type !== "audio") {
return {
status: true,
downloadUrl: `${directUrl}&title=${titleSlug || "video"}-ytshorts.savetube.vip`,
};
}
const downloadType = type === "audio" || quality === "128" ? "audio" : "video";
const postData = {
downloadType,
quality: String(quality),
key,
};
const res = await axios.post(`https://${cdn}/download`, postData, {
headers: DEFAULT_HEADERS,
timeout: 25000,
});
const body = res.data;
if (!body || body.status === false || !body.data?.downloadUrl) {
throw new Error(body?.message || "Gagal mendapatkan download link dari YTMP3");
}
return {
status: true,
downloadUrl: body.data.downloadUrl,
};
}
/**
* 5. Helper Upload ke Vamx CDN (opsional)
*/
async function uploadToVamxCdn(fileUrl, filename = "media.mp3") {
if (!fileUrl || !fileUrl.startsWith("http")) return fileUrl;
try {
const res = await fetch(fileUrl, {
headers: {
"User-Agent": DEFAULT_HEADERS["User-Agent"],
},
});
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 {
// Fallback jika upload CDN gagal
}
return fileUrl;
}
/**
* 6. Download MP3 Langsung dari YouTube URL
*/
async function downloadMp3(youtubeUrl, options = {}) {
const { cdn, data } = await getVideoInfo(youtubeUrl);
const dl = await getDownloadUrl({
key: data.key,
titleSlug: data.titleSlug,
quality: "128",
type: "audio",
cdnHost: cdn,
});
let audioUrl = dl.downloadUrl;
let thumbUrl = data.thumbnail;
if (options.saveToCdn) {
audioUrl = await uploadToVamxCdn(audioUrl, `${data.titleSlug || "audio"}.mp3`);
if (thumbUrl) {
thumbUrl = await uploadToVamxCdn(thumbUrl, `thumb_${data.id}.webp`);
}
}
return {
status: true,
title: data.title,
id: data.id,
duration: data.duration,
durationLabel: data.durationLabel,
thumbnail: thumbUrl,
type: "audio",
format: "mp3",
quality: "320kbps",
downloadUrl: audioUrl,
};
}
/**
* 7. Download MP4 Langsung dari YouTube URL
*/
async function downloadMp4(youtubeUrl, quality = "720", options = {}) {
const { cdn, data } = await getVideoInfo(youtubeUrl);
// Cari direct URL jika ada (misal 360p)
let directUrl = null;
if (data.video_formats && Array.isArray(data.video_formats)) {
const match = data.video_formats.find(
(f) => String(f.quality) === String(quality) || String(f.height) === String(quality)
);
if (match && match.url) {
directUrl = match.url;
}
}
const dl = await getDownloadUrl({
key: data.key,
titleSlug: data.titleSlug,
quality: String(quality),
type: "video",
directUrl,
cdnHost: cdn,
});
let videoUrl = dl.downloadUrl;
let thumbUrl = data.thumbnail;
if (options.saveToCdn) {
videoUrl = await uploadToVamxCdn(videoUrl, `${data.titleSlug || "video"}_${quality}p.mp4`);
if (thumbUrl) {
thumbUrl = await uploadToVamxCdn(thumbUrl, `thumb_${data.id}.webp`);
}
}
return {
status: true,
title: data.title,
id: data.id,
duration: data.duration,
durationLabel: data.durationLabel,
thumbnail: thumbUrl,
type: "video",
format: "mp4",
quality: `${quality}p`,
downloadUrl: videoUrl,
};
}
/**
* 8. All-in-one Scraper: Mengambil info lengkap, link MP3, dan link MP4 terbaik
*/
async function scrapeYttmp3(youtubeUrl, options = {}) {
const { cdn, data } = await getVideoInfo(youtubeUrl);
// Ambil link MP3
const mp3Dl = await getDownloadUrl({
key: data.key,
titleSlug: data.titleSlug,
quality: "128",
type: "audio",
cdnHost: cdn,
});
// Tentukan kualitas MP4 default (pilih 720p atau yang tersedia)
const availableVideoQualities = (data.video_formats || []).map((f) => String(f.quality || f.height));
const preferredQuality = ["720", "1080", "480", "360"].find((q) => availableVideoQualities.includes(q)) || "720";
let directUrl = null;
const matchFmt = (data.video_formats || []).find((f) => String(f.quality || f.height) === preferredQuality);
if (matchFmt && matchFmt.url) directUrl = matchFmt.url;
const mp4Dl = await getDownloadUrl({
key: data.key,
titleSlug: data.titleSlug,
quality: preferredQuality,
type: "video",
directUrl,
cdnHost: cdn,
});
let audioUrl = mp3Dl.downloadUrl;
let videoUrl = mp4Dl.downloadUrl;
let thumbUrl = data.thumbnail;
if (options.saveToCdn) {
audioUrl = await uploadToVamxCdn(audioUrl, `${data.titleSlug || "audio"}.mp3`);
videoUrl = await uploadToVamxCdn(videoUrl, `${data.titleSlug || "video"}_${preferredQuality}p.mp4`);
if (thumbUrl) {
thumbUrl = await uploadToVamxCdn(thumbUrl, `thumb_${data.id}.webp`);
}
}
return {
status: true,
result: {
id: data.id,
title: data.title,
titleSlug: data.titleSlug,
url: data.url,
thumbnail: thumbUrl,
duration: data.duration,
durationLabel: data.durationLabel,
mp3: {
format: "mp3",
quality: "320kbps",
downloadUrl: audioUrl,
},
mp4: {
format: "mp4",
quality: `${preferredQuality}p`,
downloadUrl: videoUrl,
},
availableQualities: {
audio: ["128 (MP3 320kbps)"],
video: availableVideoQualities.filter((v, i, a) => a.indexOf(v) === i),
},
},
};
}
// Module Exports
if (typeof module !== "undefined" && module.exports) {
module.exports = {
getRandomCdn,
decryptPayload,
getVideoInfo,
getDownloadUrl,
downloadMp3,
downloadMp4,
scrapeYttmp3,
};
}
// CLI Execution Handler
if (require.main === module) {
const args = process.argv.slice(2);
if (args.length === 0) {
console.log("=================================================");
console.log(" YTMP3 (yttmp3.com.co) Scraper CLI");
console.log("=================================================");
console.log("Penggunaan:");
console.log(" node yttmp3.js <youtube_url> # Download MP3 + MP4 + Info");
console.log(" node yttmp3.js mp3 <youtube_url> # Download MP3 saja");
console.log(" node yttmp3.js mp4 <youtube_url> [quality]# Download MP4 (default 720)");
console.log(" node yttmp3.js info <youtube_url> # Metadata & Format Lengkap");
console.log("");
console.log("Contoh:");
console.log(" node yttmp3.js 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'");
console.log(" node yttmp3.js mp3 'https://youtu.be/kJQP7kiw5Fk'");
console.log(" node yttmp3.js mp4 'https://youtu.be/kJQP7kiw5Fk' 1080");
process.exit(0);
}
let command = "all";
let targetUrl = "";
let quality = "720";
if (["mp3", "mp4", "info", "all"].includes(args[0].toLowerCase())) {
command = args[0].toLowerCase();
targetUrl = args[1];
if (args[2]) quality = args[2];
} else {
targetUrl = args[0];
}
if (!targetUrl) {
console.error("Error: YouTube URL tidak ditemukan.");
process.exit(1);
}
(async () => {
try {
console.log(`[YTMP3] Memproses: ${targetUrl} ...`);
let result;
if (command === "mp3") {
result = await downloadMp3(targetUrl);
} else if (command === "mp4") {
result = await downloadMp4(targetUrl, quality);
} else if (command === "info") {
const { data } = await getVideoInfo(targetUrl);
result = { status: true, result: data };
} else {
result = await scrapeYttmp3(targetUrl);
}
console.log("\n[Hasil JSON]:");
console.log(JSON.stringify(result, null, 2));
} catch (err) {
console.error("\n[Error]", err.message);
process.exit(1);
}
})();
}