downloaderjavascript5214
Spotdown - Spotify Music Downloader & Metadata Scraper
Scraper Spotify music downloader & metadata resolver cepat tanpa YouTube dependency. Mendukung link track resmi Spotify dan pencarian langsung judul lagu.
Vamz Spectre19 Okt 2026299 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/spotdown" -o spotdown.js
# 2. Jalankan script
node spotdown.js
Dependencies npm yang Dibutuhkan:
npm install {"axios":"^1.7.0"}Panduan Penggunaan:
curl -sL "https://code.vamxapi.my.id/snippet/raw/spotdown" -o spotdown.js node spotdown.js "https://open.spotify.com/track/4cOdK2wGLETKBW3PvgPWqT" node spotdown.js "Coldplay Yellow"
spotdown.js(299 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
/**
* Spotdown - Spotify Music Downloader & Metadata Scraper
* Author: Vamz Spectre (VamxAPI)
*
* Fitur:
* - Download musik Spotify ke format audio jernih (up to 320kbps)
* - Support direct Spotify Track URL (https://open.spotify.com/track/...)
* - Support pencarian langsung dengan judul lagu / nama artis
* - Resolusi metadata resmi Spotify (Judul, Artis, Album, Durasi, Cover HD)
* - Didukung Vamx High-Speed Native Stream & Deezer Music Catalog
* - Output format JSON murni & production-ready untuk bot WhatsApp & API
*
* Penggunaan CLI:
* curl -sL "https://code.vamxapi.my.id/snippet/raw/spotdown" -o spotdown.js
* node spotdown.js "https://open.spotify.com/track/4cOdK2wGLETKBW3PvgPWqT"
* node spotdown.js "Komang Raim Laode"
*/
const axios = require("axios");
const DEFAULT_HEADERS = {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
Accept: "application/json, text/plain, */*",
};
const VAMX_API_URL = process.env.VAMX_API_URL || "https://vamxapi.my.id";
const VAMX_INTERNAL_URL = "http://127.0.0.1:10319";
const VAMX_MASTER_KEY = "vamx_live_admin_master_key";
/**
* Format detik ke format menit:detik (MM:SS)
*/
function formatSeconds(sec) {
if (!sec || isNaN(sec)) return "0:00";
const m = Math.floor(sec / 60);
const s = Math.floor(sec % 60);
return `${m}:${s.toString().padStart(2, "0")}`;
}
/**
* Ekstraksi Track ID dari URL Spotify
*/
function extractSpotifyTrackId(input) {
if (!input) return null;
const str = String(input).trim();
if (/^[a-zA-Z0-9]{22}$/.test(str)) return str;
const match = str.match(/track\/([a-zA-Z0-9]{22})/i);
return match ? match[1] : null;
}
/**
* Mengambil metadata resmi track Spotify via oEmbed & Web Embed
*/
async function getSpotifyMeta(trackUrlOrId) {
const trackId = extractSpotifyTrackId(trackUrlOrId);
const trackUrl = trackId ? `https://open.spotify.com/track/${trackId}` : trackUrlOrId;
let title = "Spotify Music";
let artist = "Unknown Artist";
let album = "";
let thumbnail = "";
let duration = "-";
// 1. Coba oEmbed resmi Spotify
try {
const { data } = await axios.get(
`https://open.spotify.com/oembed?url=${encodeURIComponent(trackUrl)}`,
{ headers: DEFAULT_HEADERS, timeout: 8000 }
);
if (data?.title) title = data.title;
if (data?.thumbnail_url) thumbnail = data.thumbnail_url;
} catch {}
// 2. Coba Spotify Embed State
if (trackId) {
try {
const { data: html } = await axios.get(
`https://open.spotify.com/embed/track/${trackId}`,
{ headers: DEFAULT_HEADERS, timeout: 8000 }
);
const match = html.match(/<script id="__NEXT_DATA__" type="application\/json">({.+?})<\/script>/);
if (match) {
const parsed = JSON.parse(match[1]);
const entity = parsed.props?.pageProps?.state?.data?.entity;
if (entity) {
if (entity.name) title = entity.name;
if (Array.isArray(entity.artists) && entity.artists.length > 0) {
artist = entity.artists.map((a) => a.name).join(", ");
}
if (entity.album?.name) album = entity.album.name;
if (entity.duration) {
duration = formatSeconds(Math.floor(entity.duration / 1000));
}
}
}
} catch {}
}
if (artist === "Unknown Artist" && title.includes(" - ")) {
const parts = title.split(" - ");
artist = parts[0].trim();
title = parts.slice(1).join(" - ").trim();
}
return {
id: trackId || "spotify_track",
title,
artist,
album,
duration,
thumbnail,
spotify_url: trackUrl,
};
}
/**
* Pencarian metadata musik via Deezer Music API
*/
async function searchMusicMeta(query) {
try {
const { data } = await axios.get("https://api.deezer.com/search", {
params: { q: query, limit: 1 },
headers: DEFAULT_HEADERS,
timeout: 8000,
});
const item = data?.data?.[0];
if (item) {
return {
id: `sp_${item.id}`,
title: item.title || query,
artist: item.artist?.name || "Unknown Artist",
album: item.album?.title || "",
duration: formatSeconds(item.duration || 0),
thumbnail:
item.album?.cover_xl ||
item.album?.cover_big ||
item.album?.cover_medium ||
item.artist?.picture_big ||
"",
preview_url: item.preview || null,
spotify_url: `https://open.spotify.com/search/${encodeURIComponent(query)}`,
};
}
} catch {}
return null;
}
/**
* Resolusi unduhan audio streaming Spotify via Vamx High-Speed Gateway
*/
async function resolveAudioStream(queryOrUrl) {
const isUrl = /^https?:\/\//i.test(queryOrUrl);
const param = isUrl ? { url: queryOrUrl } : { q: queryOrUrl };
// 1. Coba koneksi internal localhost jika berjalan di server yang sama
try {
const res = await axios.get(`${VAMX_INTERNAL_URL}/api/v1/download/spotify`, {
params: param,
headers: {
"x-api-key": VAMX_MASTER_KEY,
Accept: "application/json",
},
timeout: 15000,
});
const resData = res.data?.result || res.data?.data;
if (resData?.download_url) {
return {
download_url: resData.download_url,
title: resData.title,
artist: resData.artist,
album: resData.album,
duration: resData.duration,
thumbnail: resData.thumbnail || resData.cover,
engine: "Spotdown Core (Vamx High-Speed Native Stream)",
};
}
} catch {}
// 2. Coba gateway public VamxAPI
try {
const res = await axios.get(`${VAMX_API_URL}/api/v1/download/spotify`, {
params: param,
headers: {
"x-api-key": VAMX_MASTER_KEY,
Accept: "application/json",
},
timeout: 20000,
});
const resData = res.data?.result || res.data?.data;
if (resData?.download_url) {
return {
download_url: resData.download_url,
title: resData.title,
artist: resData.artist,
album: resData.album,
duration: resData.duration,
thumbnail: resData.thumbnail || resData.cover,
engine: "Spotdown Core (Vamx High-Speed Native Stream)",
};
}
} catch {}
return null;
}
/**
* Main scraper function: Spotdown Spotify Downloader
* @param {string} input - Spotify URL (https://open.spotify.com/track/...) atau Judul Lagu
* @returns {Promise<object>}
*/
async function spotdown(input) {
const cleanInput = String(input || "").trim();
if (!cleanInput) {
return {
status: false,
creator: "Vamz Spectre",
message: "Parameter link Spotify atau judul lagu wajib disertakan.",
};
}
const isSpotifyUrl =
cleanInput.includes("open.spotify.com/track/") ||
cleanInput.includes("spotify.link/") ||
/^[a-zA-Z0-9]{22}$/.test(cleanInput);
let meta = null;
if (isSpotifyUrl) {
meta = await getSpotifyMeta(cleanInput);
} else {
meta = await searchMusicMeta(cleanInput);
if (!meta) {
meta = {
id: "search_track",
title: cleanInput,
artist: "Spotify Music",
album: "",
duration: "-",
thumbnail: "",
spotify_url: `https://open.spotify.com/search/${encodeURIComponent(cleanInput)}`,
};
}
}
// Resolusi link unduhan stream
const streamResult = await resolveAudioStream(isSpotifyUrl ? meta.spotify_url : cleanInput);
if (!streamResult && !meta.preview_url) {
return {
status: false,
creator: "Vamz Spectre",
message: `Gagal mendapatkan link download audio untuk "${meta.title || cleanInput}".`,
};
}
return {
status: true,
creator: "Vamz Spectre",
data: {
title: streamResult?.title || meta.title,
artist: streamResult?.artist || meta.artist,
album: streamResult?.album || meta.album || "-",
duration: streamResult?.duration || meta.duration || "-",
thumbnail: streamResult?.thumbnail || meta.thumbnail || "",
download_url: streamResult?.download_url || meta.preview_url,
spotify_url: meta.spotify_url,
engine: streamResult?.engine || "Spotdown Audio Engine",
},
};
}
module.exports = { spotdown };
// CLI Runner
if (require.main === module) {
const query = process.argv[2] || "https://open.spotify.com/track/4cOdK2wGLETKBW3PvgPWqT";
spotdown(query)
.then((res) => console.log(JSON.stringify(res, null, 2)))
.catch((err) => {
console.error(
JSON.stringify(
{
status: false,
creator: "Vamz Spectre",
message: err.message || "Terjadi kesalahan internal.",
},
null,
2
)
);
process.exit(1);
});
}