canvasjavascript3945
Fake Spotify Canvas Generator
1:1 Pixel-accurate clone Spotify Mobile Now Playing screen dengan clean status bar, dynamic ambient background, font Spotify (Poppins), seekbar, dan fast cache.
Vamz Spectre19 Okt 2026654 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/fakespotify" -o fakespotify.js
# 2. Jalankan script
node fakespotify.js
Dependencies npm yang Dibutuhkan:
npm install skia-canvas, sharp, axios, form-dataPanduan Penggunaan:
node fakespotify.js --title "Bersenja Gurau" --artist "Raim Laode" --clock "18.21" --battery 18
fakespotify.js(654 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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
/**
* Fake Spotify Canvas - 1:1 Pixel-Accurate Spotify Mobile Player Mockup Generator
* Author: Vamz Spectre (VamxAPI)
*
* Fitur:
* - 1:1 Pixel-accurate clone tampilan Spotify Now Playing Mobile (1080 x 2344, 19.5:9)
* - Customization lengkap: Cover album/foto, Judul lagu, Nama artis/author, Jam status bar,
* Persentase baterai, Judul & Subtitle playlist, Durasi lagu & Current time, State Play/Pause.
* - Dynamic Ambient Background: Otomatis mendeteksi warna dominan album cover menggunakan sharp
* dan menghasilkan dynamic ambient gradient khas Spotify Mobile.
* - High-Resolution typography dengan font Spotify / Poppins (Bold, Medium, Regular).
* - Auto-Upload ke Vamx Media CDN (https://cdn.vamxapi.my.id/m/...) untuk bot WhatsApp & Telegram.
*
* Penggunaan CLI:
* curl -sL "https://code.vamxapi.my.id/snippet/raw/fakespotify" -o fakespotify.js
* node fakespotify.js --title "Bersenja Gurau" --artist "Raim Laode" --clock "18.21" --battery 18
* node fakespotify.js '{"title":"Sialan","artist":"Juicy Luicy","duration":"3:45","currentTime":"1:20"}'
*/
const fs = require("fs");
const path = require("path");
const axios = require("axios");
const FormData = require("form-data");
const sharp = require("sharp");
const { Canvas, FontLibrary, loadImage } = require("skia-canvas");
const VAMX_CDN_UPLOAD_ENDPOINT = "https://cdn.vamxapi.my.id/api/v1/media/upload";
// Registrasi Font Spotify (Poppins)
const FONT_DIR = "/root/websiteapi/assets/fonts/canvas";
try {
if (fs.existsSync(path.join(FONT_DIR, "Poppins-Bold.ttf"))) {
FontLibrary.use("SpotifyBold", path.join(FONT_DIR, "Poppins-Bold.ttf"));
}
if (fs.existsSync(path.join(FONT_DIR, "Poppins-Medium.ttf"))) {
FontLibrary.use("SpotifyMedium", path.join(FONT_DIR, "Poppins-Medium.ttf"));
}
if (fs.existsSync(path.join(FONT_DIR, "Poppins-Regular.ttf"))) {
FontLibrary.use("SpotifyRegular", path.join(FONT_DIR, "Poppins-Regular.ttf"));
}
if (fs.existsSync(path.join(FONT_DIR, "Poppins-SemiBold.ttf"))) {
FontLibrary.use("SpotifySemiBold", path.join(FONT_DIR, "Poppins-SemiBold.ttf"));
}
} catch (e) {
// Fallback ke system font jika gagal
}
/**
* Konversi format mm:ss ke detik
*/
function parseTimeToSeconds(timeStr) {
if (!timeStr || typeof timeStr !== "string") return 0;
const parts = timeStr.split(":").map(Number);
if (parts.length === 2) return parts[0] * 60 + parts[1];
if (parts.length === 3) return parts[0] * 3600 + parts[1] * 60 + parts[2];
return Number(timeStr) || 0;
}
/**
* Upload gambar hasil render ke Vamx Media CDN
*/
async function uploadToVamxCdn(buffer, filename = "fakespotify.png") {
const form = new FormData();
form.append("file", buffer, {
filename,
contentType: "image/png",
});
const response = await axios.post(VAMX_CDN_UPLOAD_ENDPOINT, form, {
headers: {
...form.getHeaders(),
"x-client-mode": "vamx-cdn",
},
timeout: 30000,
maxBodyLength: Infinity,
maxContentLength: Infinity,
});
const mediaUrl = response.data?.data?.media?.url || response.data?.result?.media?.url || response.data?.data?.url;
if (response.data && response.data.status && mediaUrl) {
return mediaUrl;
}
throw new Error(response.data?.message || "Gagal mengunggah ke CDN Vamx.");
}
/**
* Mengambil Buffer gambar dari URL atau file lokal
*/
async function resolveImageBuffer(input) {
if (Buffer.isBuffer(input)) return input;
if (typeof input === "string") {
if (input.startsWith("http://") || input.startsWith("https://")) {
const res = await axios.get(input, { responseType: "arraybuffer", timeout: 15000 });
return Buffer.from(res.data);
}
if (fs.existsSync(input)) {
return fs.readFileSync(input);
}
}
return null;
}
/**
* Extract Dominant Color dari album cover menggunakan sharp
*/
async function extractDominantColor(imageBuffer) {
try {
const { data } = await sharp(imageBuffer)
.resize(1, 1, { fit: "cover" })
.raw()
.toBuffer({ resolveWithObject: true });
return [data[0], data[1], data[2]];
} catch {
// Default Spotify Warm Ochre/Brown
return [118, 48, 28];
}
}
/**
* Generate Fake Spotify Canvas
*/
async function generateFakeSpotify(options = {}) {
const {
cover = "/tmp/bd316671-7255-455e-8267-4608ebc5e2ad.jpg",
title = "Bersenja Gurau",
artist = "Raim Laode",
playlistTitle = "Radio Bersenja Gurau",
playlistDesc = "Memainkan dari Playlist",
duration = "3:14",
currentTime = "0:00",
clock = "18.21",
battery = "18",
isPlaying = false,
shuffle = true,
lyricsTitle = "Pratinjau lirik",
uploadCdn = true,
} = options;
const W = 1080;
const H = 2344;
const canvas = new Canvas(W, H);
const ctx = canvas.getContext("2d");
// 1. Resolve Cover & Dominant Color
let coverBuffer = null;
try {
coverBuffer = await resolveImageBuffer(cover);
} catch {}
// Fallback dummy cover jika cover tidak ditemukan
if (!coverBuffer) {
if (fs.existsSync("/tmp/bd316671-7255-455e-8267-4608ebc5e2ad.jpg")) {
coverBuffer = fs.readFileSync("/tmp/bd316671-7255-455e-8267-4608ebc5e2ad.jpg");
} else {
// Buat square cover placeholder
coverBuffer = await sharp({
create: {
width: 936,
height: 936,
channels: 3,
background: { r: 120, g: 50, b: 30 },
},
}).jpeg().toBuffer();
}
}
const [domR, domG, domB] = await extractDominantColor(coverBuffer);
// 2. Background Gradient (Ambient Lighting khas Spotify)
const bgGrad = ctx.createLinearGradient(0, 0, 0, H);
bgGrad.addColorStop(0, `rgb(${domR}, ${domG}, ${domB})`);
bgGrad.addColorStop(0.35, `rgb(${Math.floor(domR * 0.7)}, ${Math.floor(domG * 0.7)}, ${Math.floor(domB * 0.7)})`);
bgGrad.addColorStop(0.65, `rgb(${Math.floor(domR * 0.25)}, ${Math.floor(domG * 0.25)}, ${Math.floor(domB * 0.25)})`);
bgGrad.addColorStop(0.85, "#121212");
bgGrad.addColorStop(1, "#121212");
ctx.fillStyle = bgGrad;
ctx.fillRect(0, 0, W, H);
// 3. Status Bar (y = 50..90)
// Clock (Kiri)
ctx.fillStyle = "#ffffff";
ctx.font = "28px SpotifyBold";
ctx.textAlign = "left";
ctx.fillText(String(clock), 60, 78);
// Notification / App dots
const notifColors = ["#00bcd4", "#26a69a", "#4285f4", "#5c6bc0"];
notifColors.forEach((color, idx) => {
ctx.beginPath();
ctx.arc(195 + idx * 26, 70, 7.5, 0, Math.PI * 2);
ctx.fillStyle = color;
ctx.fill();
});
// Small dot
ctx.beginPath();
ctx.arc(195 + notifColors.length * 26 + 10, 70, 3, 0, Math.PI * 2);
ctx.fillStyle = "#ffffff";
ctx.fill();
// Status Bar Kanan: VoLTE 4G+ & Signal Bars
ctx.font = "22px SpotifyBold";
ctx.textAlign = "right";
ctx.fillText("Vo LTE", 740, 78);
ctx.fillText("4G+", 785, 70);
// 4 Signal Bars
for (let b = 0; b < 4; b++) {
const bh = 10 + b * 5;
ctx.fillRect(810 + b * 9, 80 - bh, 6, bh);
}
// Battery Box & Percentage
const batX = 875, batY = 52, batW = 68, batH = 34;
ctx.strokeStyle = "rgba(255, 255, 255, 0.7)";
ctx.lineWidth = 3;
ctx.beginPath();
ctx.roundRect(batX, batY, batW, batH, 8);
ctx.stroke();
// Battery Tip (Kanan)
ctx.fillStyle = "rgba(255, 255, 255, 0.7)";
ctx.fillRect(batX + batW, batY + 10, 4, 14);
// Persentase Baterai
const batVal = parseInt(battery, 10) || 18;
ctx.fillStyle = batVal <= 20 ? "#ffb703" : "#ffffff";
ctx.font = "20px SpotifyBold";
ctx.textAlign = "center";
ctx.fillText(String(battery).replace("%", ""), batX + batW / 2, batY + 25);
// 4. Navigation Header (y = 150..250)
// Chevron Down
ctx.beginPath();
ctx.moveTo(70, 185);
ctx.lineTo(88, 203);
ctx.lineTo(106, 185);
ctx.strokeStyle = "#ffffff";
ctx.lineWidth = 5;
ctx.lineCap = "round";
ctx.lineJoin = "round";
ctx.stroke();
// Subtitle ("Memainkan dari Playlist")
ctx.textAlign = "center";
ctx.fillStyle = "rgba(255, 255, 255, 0.75)";
ctx.font = "28px SpotifyRegular";
ctx.fillText(playlistDesc, 540, 182);
// Playlist Title ("Radio Bersenja Gurau")
ctx.fillStyle = "#ffffff";
ctx.font = "34px SpotifyBold";
ctx.fillText(playlistTitle, 540, 230);
// Three dots menu (Kanan)
ctx.fillStyle = "#ffffff";
[186, 203, 220].forEach(dy => {
ctx.beginPath();
ctx.arc(980, dy, 4.5, 0, Math.PI * 2);
ctx.fill();
});
// 5. Album Cover Artwork (y = 368..1304)
const coverX = 72;
const coverY = 368;
const coverSize = 936;
const coverRadius = 24;
ctx.save();
// Drop Shadow realistis di belakang album art
ctx.shadowColor = "rgba(0, 0, 0, 0.65)";
ctx.shadowBlur = 45;
ctx.shadowOffsetY = 22;
// Load Album Image
let coverImg;
try {
coverImg = await loadImage(coverBuffer);
} catch {
coverImg = null;
}
ctx.beginPath();
ctx.roundRect(coverX, coverY, coverSize, coverSize, coverRadius);
ctx.clip();
if (coverImg) {
ctx.drawImage(coverImg, coverX, coverY, coverSize, coverSize);
} else {
ctx.fillStyle = `rgb(${domR}, ${domG}, ${domB})`;
ctx.fillRect(coverX, coverY, coverSize, coverSize);
}
ctx.restore();
// 6. Track Details & Action Buttons (y = 1440..1560)
ctx.textAlign = "left";
ctx.fillStyle = "#ffffff";
ctx.font = "56px SpotifyBold";
// Truncate jika judul lagu terlalu panjang
let displayTitle = title;
if (ctx.measureText(displayTitle).width > 580) {
while (ctx.measureText(displayTitle + "...").width > 580 && displayTitle.length > 0) {
displayTitle = displayTitle.slice(0, -1);
}
displayTitle += "...";
}
ctx.fillText(displayTitle, 72, 1485);
ctx.fillStyle = "rgba(255, 255, 255, 0.65)";
ctx.font = "38px SpotifyMedium";
let displayArtist = artist;
if (ctx.measureText(displayArtist).width > 580) {
while (ctx.measureText(displayArtist + "...").width > 580 && displayArtist.length > 0) {
displayArtist = displayArtist.slice(0, -1);
}
displayArtist += "...";
}
ctx.fillText(displayArtist, 72, 1545);
// Tombol Cross ✕ (Hide from playlist)
const cx = 730, cy = 1505, cs = 22;
ctx.beginPath();
ctx.moveTo(cx - cs, cy - cs);
ctx.lineTo(cx + cs, cy + cs);
ctx.moveTo(cx + cs, cy - cs);
ctx.lineTo(cx - cs, cy + cs);
ctx.strokeStyle = "#ffffff";
ctx.lineWidth = 6;
ctx.lineCap = "round";
ctx.stroke();
// Tombol Plus ⊕ (Add to Liked Songs)
const px = 890, py = 1505;
ctx.beginPath();
ctx.arc(px, py, 40, 0, Math.PI * 2);
ctx.strokeStyle = "#ffffff";
ctx.lineWidth = 5;
ctx.stroke();
const ps = 18;
ctx.beginPath();
ctx.moveTo(px - ps, py);
ctx.lineTo(px + ps, py);
ctx.moveTo(px, py - ps);
ctx.lineTo(px, py + ps);
ctx.lineWidth = 5;
ctx.lineCap = "round";
ctx.stroke();
// 7. Progress Seekbar (y = 1640..1700)
const barX = 72, barY = 1640, barW = 936, barH = 6;
ctx.fillStyle = "rgba(255, 255, 255, 0.25)";
ctx.beginPath();
ctx.roundRect(barX, barY, barW, barH, 3);
ctx.fill();
// Hitung played progress ratio
const curSec = parseTimeToSeconds(currentTime);
const durSec = Math.max(1, parseTimeToSeconds(duration));
let playedRatio = curSec / durSec;
if (isNaN(playedRatio) || playedRatio < 0.01) playedRatio = 0.01;
if (playedRatio > 1.0) playedRatio = 1.0;
// Played bar
ctx.fillStyle = "#ffffff";
ctx.beginPath();
ctx.roundRect(barX, barY, Math.max(6, barW * playedRatio), barH, 3);
ctx.fill();
// Progress handle thumb dot
const thumbX = barX + barW * playedRatio;
ctx.beginPath();
ctx.arc(thumbX, barY + barH / 2, 11, 0, Math.PI * 2);
ctx.fillStyle = "#ffffff";
ctx.fill();
// Time labels
ctx.font = "26px SpotifyMedium";
ctx.fillStyle = "rgba(255, 255, 255, 0.6)";
ctx.textAlign = "left";
ctx.fillText(String(currentTime), 72, 1690);
ctx.textAlign = "right";
ctx.fillText(String(duration), 1008, 1690);
// 8. Main Controls Row (y = 1840)
// Shuffle Button
const shX = 100, shY = 1840;
ctx.strokeStyle = shuffle ? "#1ed760" : "rgba(255, 255, 255, 0.65)";
ctx.lineWidth = 4.5;
ctx.lineCap = "round";
ctx.beginPath();
ctx.moveTo(shX - 24, shY - 14);
ctx.lineTo(shX - 8, shY - 14);
ctx.lineTo(shX + 8, shY + 14);
ctx.lineTo(shX + 24, shY + 14);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(shX - 24, shY + 14);
ctx.lineTo(shX - 8, shY + 14);
ctx.lineTo(shX - 2, shY + 5);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(shX + 2, shY - 5);
ctx.lineTo(shX + 8, shY - 14);
ctx.lineTo(shX + 24, shY - 14);
ctx.stroke();
if (shuffle) {
ctx.beginPath();
ctx.arc(shX, shY + 30, 4.5, 0, Math.PI * 2);
ctx.fillStyle = "#1ed760";
ctx.fill();
}
// Previous Button (|◀)
const prX = 290, prY = 1840;
ctx.fillStyle = "#ffffff";
ctx.fillRect(prX - 26, prY - 24, 6, 48);
ctx.beginPath();
ctx.moveTo(prX + 20, prY - 25);
ctx.lineTo(prX - 16, prY);
ctx.lineTo(prX + 20, prY + 25);
ctx.closePath();
ctx.fill();
// Big Play/Pause Button Circle
const plX = 540, plY = 1840, plR = 90;
ctx.beginPath();
ctx.arc(plX, plY, plR, 0, Math.PI * 2);
ctx.fillStyle = "#ffffff";
ctx.fill();
if (isPlaying) {
// Pause Icon (dua balok hitam vertikal)
ctx.fillStyle = "#000000";
ctx.fillRect(plX - 22, plY - 25, 14, 50);
ctx.fillRect(plX + 8, plY - 25, 14, 50);
} else {
// Play Triangle
ctx.beginPath();
ctx.moveTo(plX - 14, plY - 26);
ctx.lineTo(plX + 26, plY);
ctx.lineTo(plX - 14, plY + 26);
ctx.closePath();
ctx.fillStyle = "#000000";
ctx.fill();
}
// Next Button (▶|)
const nxX = 790, nxY = 1840;
ctx.fillStyle = "#ffffff";
ctx.fillRect(nxX + 20, nxY - 24, 6, 48);
ctx.beginPath();
ctx.moveTo(nxX - 20, nxY - 25);
ctx.lineTo(nxX + 16, nxY);
ctx.lineTo(nxX - 20, nxY + 25);
ctx.closePath();
ctx.fill();
// Sleep Timer Icon (Stopwatch)
const tiX = 975, tiY = 1840;
ctx.beginPath();
ctx.arc(tiX, tiY, 26, 0, Math.PI * 2);
ctx.strokeStyle = "#ffffff";
ctx.lineWidth = 4.5;
ctx.stroke();
ctx.fillRect(tiX - 4, tiY - 34, 8, 7);
ctx.beginPath();
ctx.moveTo(tiX, tiY);
ctx.lineTo(tiX, tiY - 14);
ctx.moveTo(tiX, tiY);
ctx.lineTo(tiX + 10, tiY + 6);
ctx.strokeStyle = "#ffffff";
ctx.lineWidth = 3.5;
ctx.stroke();
// 9. Bottom Icons Row (y = 2070)
// Device Connect (Kiri)
const devX = 85, devY = 2070;
ctx.strokeStyle = "#ffffff";
ctx.lineWidth = 4;
ctx.beginPath();
ctx.roundRect(devX - 22, devY - 18, 44, 36, 6);
ctx.stroke();
ctx.beginPath();
ctx.arc(devX, devY, 7, 0, Math.PI * 2);
ctx.fillStyle = "#ffffff";
ctx.fill();
// Share Icon
const shIX = 765, shIY = 2070;
const sPts = [
{ x: shIX - 14, y: shIY },
{ x: shIX + 14, y: shIY - 14 },
{ x: shIX + 14, y: shIY + 14 },
];
ctx.strokeStyle = "#ffffff";
ctx.lineWidth = 3.5;
ctx.beginPath();
ctx.moveTo(sPts[1].x, sPts[1].y);
ctx.lineTo(sPts[0].x, sPts[0].y);
ctx.lineTo(sPts[2].x, sPts[2].y);
ctx.stroke();
sPts.forEach(p => {
ctx.beginPath();
ctx.arc(p.x, p.y, 6, 0, Math.PI * 2);
ctx.fillStyle = "#ffffff";
ctx.fill();
});
// Queue Icon (3 bars horizontal)
const qX = 910, qY = 2070;
ctx.fillStyle = "#ffffff";
ctx.beginPath();
ctx.roundRect(qX - 22, qY - 14, 44, 5, 2.5);
ctx.roundRect(qX - 22, qY - 2, 44, 5, 2.5);
ctx.roundRect(qX - 22, qY + 10, 44, 5, 2.5);
ctx.fill();
// 10. Bottom Lyrics Preview Banner (y = 2200..2344)
const lyrY = 2200;
// Kontras dinamis dari dominant color
const lyricCardColor = `rgb(${Math.min(255, Math.floor(domR * 1.15) + 20)}, ${Math.floor(domG * 0.45)}, ${Math.floor(domB * 0.45)})`;
ctx.fillStyle = lyricCardColor;
ctx.beginPath();
ctx.roundRect(40, lyrY, 1000, 200, 32);
ctx.fill();
ctx.fillStyle = "#ffffff";
ctx.font = "40px SpotifyBold";
ctx.textAlign = "left";
ctx.fillText(lyricsTitle, 95, lyrY + 70);
// Android Bottom Home Bar Pill
ctx.fillStyle = "#ffffff";
ctx.beginPath();
ctx.roundRect(540 - 160, 2320, 320, 8, 4);
ctx.fill();
// Export Buffer PNG
const buffer = await canvas.toBuffer("png");
// Upload ke CDN Vamx jika diaktifkan
let cdnUrl = null;
if (uploadCdn) {
try {
cdnUrl = await uploadToVamxCdn(buffer, `fakespotify_${Date.now()}.png`);
} catch {}
}
return {
buffer,
url: cdnUrl,
width: W,
height: H,
meta: {
title,
artist,
playlistTitle,
playlistDesc,
duration,
currentTime,
clock,
battery: `${battery}%`,
isPlaying,
dominantColor: `rgb(${domR}, ${domG}, ${domB})`,
},
};
}
module.exports = { generateFakeSpotify, extractDominantColor };
// CLI Execution Runner
if (require.main === module) {
const args = process.argv.slice(2);
const options = {};
if (args.length > 0 && args[0].trim().startsWith("{")) {
try {
Object.assign(options, JSON.parse(args.join(" ")));
} catch {}
} else {
for (let i = 0; i < args.length; i++) {
const arg = args[i];
if (arg === "--cover" && args[i + 1]) {
options.cover = args[++i];
} else if (arg === "--title" && args[i + 1]) {
options.title = args[++i];
} else if (arg === "--artist" && args[i + 1]) {
options.artist = args[++i];
} else if (arg === "--playlist" && args[i + 1]) {
options.playlistTitle = args[++i];
} else if (arg === "--playlistDesc" && args[i + 1]) {
options.playlistDesc = args[++i];
} else if (arg === "--duration" && args[i + 1]) {
options.duration = args[++i];
} else if (arg === "--currentTime" && args[i + 1]) {
options.currentTime = args[++i];
} else if (arg === "--clock" && args[i + 1]) {
options.clock = args[++i];
} else if (arg === "--battery" && args[i + 1]) {
options.battery = args[++i];
} else if (arg === "--playing") {
options.isPlaying = true;
}
}
}
generateFakeSpotify(options)
.then((res) => {
console.log(
JSON.stringify(
{
status: true,
creator: "Vamz Spectre",
data: {
url: res.url,
dimensions: `${res.width}x${res.height}`,
track: res.meta.title,
artist: res.meta.artist,
playlist: res.meta.playlistTitle,
duration: res.meta.duration,
currentTime: res.meta.currentTime,
clock: res.meta.clock,
battery: res.meta.battery,
buffer_size: `${(res.buffer.length / 1024).toFixed(2)} KB`,
},
},
null,
2
)
);
})
.catch((err) => {
console.error(
JSON.stringify(
{
status: false,
creator: "Vamz Spectre",
message: err.message || "Gagal membuat gambar fake spotify canvas.",
},
null,
2
)
);
process.exit(1);
});
}