scraperjavascript189
CUTAD - Short Drama & Donghua Streaming Scraper (20 Providers)
Scraper Node.js mandiri untuk katalog short drama dan donghua dari platform CUTAD (20 provider: DotDrama, FreeReels, NetShort, Donghua, MeloShort, DramaBite, Melolo, ReelShort, Sereal, WeTV, dll). Mendukung auto-session, pencarian judul, metadata episode, direct video stream HLS (m3u8), dan subtitle Bahasa Indonesia.
Vamz Spectre4 Okt 2026762 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/cutad-drama-stream-scraper" -o cutad-drama-stream-scraper.js
# 2. Jalankan script
node cutad-drama-stream-scraper.js
Dependencies npm yang Dibutuhkan:
npm install none (Native Fetch / Node.js 18+)Panduan Penggunaan:
// Persyaratan: Node.js v18+ (Pure Native Fetch, tanpa external dependencies)
// 1. Eksekusi langsung via CLI:
node cutad-drama-stream-scraper.js --providers
node cutad-drama-stream-scraper.js --rank freereels
node cutad-drama-stream-scraper.js --search "CEO" freereels
node cutad-drama-stream-scraper.js --detail freereels SZmMvZly22
node cutad-drama-stream-scraper.js --stream freereels SZmMvZly22::PcXdDbchtn
node cutad-drama-stream-scraper.js "https://www.cutad.web.id/watch/dotdrama/anak-magangku-ternyata-istriku--2094673365253947393"
// 2. Integrasi Modular di Node.js:
const { getRank, getDetail, getStream, search } = require(./cutad-drama-stream-scraper);
// Ambil drama populer
const list = await getRank('freereels');
// Detail & episode
const { detail, episodes } = await getDetail('freereels', list[0].id);
// Link streaming video m3u8 & subtitle Indonesia
const stream = await getStream('freereels', episodes[0].videoFakeId);
console.log('Stream URL:', stream.url);
// 3. Integrasi Bot WhatsApp (Baileys / VamxBotz):
case 'drama':
case 'dracin': {
const query = text.trim();
if (!query) return m.reply('❌ Masukkan judul drama: .dracin ceo');
await m.reply('⏳ Sedang mencari drama pendek...');
try {
const results = await search(query, 'freereels');
if (!results.length) return m.reply('❌ Drama tidak ditemukan.');
const drama = results[0];
const { detail, episodes } = await getDetail('freereels', drama.id);
const stream = episodes.length > 0 ? await getStream('freereels', episodes[0].videoFakeId) : null;
let caption = `🎬 *${detail.title}*\n\n`;
caption += `📦 Total Episode: ${detail.totalEpisodes}\n`;
caption += `📝 Sinopsis: ${detail.description?.slice(0, 150)}...\n\n`;
if (stream?.url) {
caption += `🍿 *Tonton Episode 1:*\n${stream.url}\n`;
}
caption += `\n⚡ *Powered by vamxapi.my.id*`;
if (detail.thumbnail) {
await conn.sendMessage(m.chat, { image: { url: detail.thumbnail }, caption: caption.trim() }, { quoted: m });
} else {
await m.reply(caption.trim());
}
} catch (err) {
await m.reply('❌ Gagal: ' + err.message);
}
break;
}cutad-drama-stream-scraper.js(762 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
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
/**
* CUTAD Scraper - Streaming Drama Pendek & Donghua Sub Indo (All 20 Providers)
* Author: Vamz Spectre (VamxAPI)
* Target: https://www.cutad.web.id/
*
* Fitur Utama:
* 1. Automatic Session Management (Auto-generate and refresh cutad_sess cookie)
* 2. 20 Provider Short Drama & Donghua:
* - DotDrama, FreeReels, NetShort, Donghua, StardustTV, MicroDrama,
* - MeloShort, StarShort, ShortSky, DramaBite, Melolo, BiliTV,
* - DramaRush, ShortMax, WeTV, Shortwave, ReelShort, ReelBuzz, Sereal, ShotShort
* 3. Operasi Lengkap:
* - List Providers
* - Rank / Popular / Trending Catalog
* - Global & Provider Search
* - Detail Drama & List Episode
* - Direct Video Stream (.m3u8 / MP4) + Subtitle Bahasa Indonesia (SRT/VTT)
* - Watch Page URL Scraper (https://www.cutad.web.id/watch/:provider/:slug)
* 4. Pure Node.js 18+ (Zero npm dependencies, built-in Native Fetch)
*/
const BASE_URL = "https://www.cutad.web.id";
const PROVIDERS = {
dotdrama: { name: "dotdrama", label: "DotDrama", endpoint: "/api/dotdrama", color: "#10b981", desc: "Drama China (Dracin) & Film Pendek" },
freereels: { name: "freereels", label: "FreeReels", endpoint: "/api/freereels", color: "#e91e63", desc: "Drama China (Dracin)" },
netshort: { name: "netshort", label: "NetShort", endpoint: "/api/netshort", color: "#ff6b35", desc: "Drama China (Dracin) & Series" },
donghua: { name: "donghua", label: "Donghua", endpoint: "/api/donghub", color: "#00b894", desc: "Anime China Sub Indo Streaming HD" },
stardusttv: { name: "stardusttv", label: "StardustTV", endpoint: "/api/stardusttv", color: "#8b5cf6", desc: "Drama China (Dracin)" },
microdrama: { name: "microdrama", label: "MicroDrama", endpoint: "/api/microdrama", color: "#3b82f6", desc: "Drama China (Dracin)" },
meloshort: { name: "meloshort", label: "MeloShort", endpoint: "/api/meloshort", color: "#ec4899", desc: "Drama China (Dracin)" },
starshort: { name: "starshort", label: "StarShort", endpoint: "/api/starshort", color: "#f43f5e", desc: "Drama China (Dracin)" },
shortsky: { name: "shortsky", label: "ShortSky", endpoint: "/api/shortsky", color: "#3b82f6", desc: "Drama China (Dracin)" },
dramabite: { name: "dramabite", label: "DramaBite", endpoint: "/api/dramabite", color: "#f97316", desc: "Drama China (Dracin)" },
melolo: { name: "melolo", label: "Melolo", endpoint: "/api/melolo", color: "#f59e0b", desc: "Drama China (Dracin)" },
bilitv: { name: "bilitv", label: "BiliTV", endpoint: "/api/bilitv", color: "#00a1d6", desc: "Drama China (Dracin)" },
dramarush: { name: "dramarush", label: "DramaRush", endpoint: "/api/dramarush", color: "#e11d48", desc: "Drama China (Dracin)" },
shortmax: { name: "shortmax", label: "ShortMax", endpoint: "/api/shortmax", color: "#e11d48", desc: "Drama China (ShortMax)" },
wetv: { name: "wetv", label: "WeTV", endpoint: "/api/wetv", color: "#00c853", desc: "Drama China & Asia (WeTV)" },
shortwave: { name: "shortwave", label: "Shortwave", endpoint: "/api/shortwave", color: "#6366f1", desc: "Drama pendek (Shortwave)" },
reelshort: { name: "reelshort", label: "ReelShort", endpoint: "/api/reelshort", color: "#e11d48", desc: "Drama pendek ReelShort — Dubbing Indonesia" },
reelbuzz: { name: "reelbuzz", label: "ReelBuzz", endpoint: "/api/reelbuzz", color: "#ff1744", desc: "Drama pendek ReelBuzz — Dubbing Indonesia" },
sereal: { name: "sereal", label: "Sereal", endpoint: "/api/sereal", color: "#7c3aed", desc: "Drama pendek Sereal — Dubbing Indonesia" },
shotshort: { name: "shotshort", label: "ShotShort", endpoint: "/api/shotshort", color: "#22c55e", desc: "Drama China (Dracin)" },
};
let cachedSession = {
cookie: "",
expiresAt: 0,
};
/**
* Mendapatkan session cookie cutad_sess secara otomatis
*/
async function getSession() {
const now = Date.now();
if (cachedSession.cookie && cachedSession.expiresAt > now) {
return cachedSession.cookie;
}
try {
const res = await fetch(BASE_URL + "/", {
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
},
signal: AbortSignal.timeout(8000),
});
const rawCookies = res.headers.getSetCookie ? res.headers.getSetCookie() : [];
const cookieHeader = res.headers.get("set-cookie") || "";
let cookieStr = rawCookies.map((c) => c.split(";")[0]).join("; ");
if (!cookieStr && cookieHeader) {
const match = cookieHeader.match(/cutad_sess=[^;]+/);
if (match) cookieStr = match[0];
}
if (cookieStr) {
cachedSession = {
cookie: cookieStr,
expiresAt: now + 90 * 60 * 1000, // 90 menit cache
};
return cookieStr;
}
} catch (err) {
console.warn("[CUTAD] Gagal mengambil session cookie baru:", err.message);
}
return cachedSession.cookie || "";
}
/**
* Helper request internal ke API cutad.web.id dengan proteksi referer & session
*/
async function requestApi(path, options = {}) {
const cookie = await getSession();
const url = path.startsWith("http") ? path : `${BASE_URL}${path}`;
const headers = {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
Referer: BASE_URL + "/",
Accept: "application/json, text/plain, */*",
...(cookie ? { Cookie: cookie } : {}),
...(options.headers || {}),
};
const res = await fetch(url, {
method: options.method || "GET",
headers,
signal: AbortSignal.timeout(options.timeout || 12000),
});
if (!res.ok) {
throw new Error(`HTTP error ${res.status}: ${res.statusText}`);
}
return await res.json();
}
/**
* Membersihkan URL proksi internal cutad menjadi direct upstream link
*/
function cleanUrl(url) {
if (!url || typeof url !== "string") return "";
if (url.includes("/api/m3u8-proxy?url=")) {
try {
const parsed = new URL(url.startsWith("http") ? url : `${BASE_URL}${url}`);
const direct = parsed.searchParams.get("url");
if (direct) return direct;
} catch {}
}
if (url.includes("/api/subtitle-proxy?url=")) {
try {
const parsed = new URL(url.startsWith("http") ? url : `${BASE_URL}${url}`);
const direct = parsed.searchParams.get("url");
if (direct) return direct;
} catch {}
}
if (url.includes("/api/proxy?u=")) {
try {
const parsed = new URL(url.startsWith("http") ? url : `${BASE_URL}${url}`);
const b64 = parsed.searchParams.get("u");
if (b64) return Buffer.from(b64, "base64").toString("utf-8");
} catch {}
}
return url;
}
/**
* 1. Mendapatkan daftar provider yang didukung
*/
function getProviders() {
return Object.values(PROVIDERS).map((p) => ({
name: p.name,
label: p.label,
desc: p.desc,
color: p.color,
}));
}
/**
* 2. Mengambil daftar drama terpopuler / trending dari provider
*/
async function getRank(provider = "freereels") {
const p = PROVIDERS[provider.toLowerCase()];
if (!p) {
throw new Error(
`Provider "${provider}" tidak dikenal. Gunakan salah satu: ${Object.keys(PROVIDERS).join(", ")}`
);
}
let items = [];
const endpoint = p.endpoint;
try {
switch (p.name) {
case "dotdrama": {
const json = await requestApi(`${endpoint}?action=list`);
items = (json.dramas || []).map((d) => ({
id: String(d.id),
provider: p.name,
title: d.title || "",
thumbnail: cleanUrl(d.cover || ""),
totalEpisodes: d.totalEpisodes || 0,
description: d.description || "",
}));
break;
}
case "netshort": {
const json = await requestApi(`${endpoint}?action=home&size=100`);
const sections = json?.data?.sections || [];
for (const sec of sections) {
for (const it of sec.items || []) {
items.push({
id: String(it.id),
provider: p.name,
title: it.title || "",
thumbnail: cleanUrl(it.cover || ""),
tags: it.labels || [],
totalEpisodes: it.episode || 0,
});
}
}
break;
}
case "donghua": {
const json = await requestApi(`${endpoint}?action=rank&cat=${encodeURIComponent("anime/?order=update")}&page=1`);
items = (json.items || []).map((it) => ({
id: String(it.id || it.url || ""),
provider: p.name,
title: it.title || "",
thumbnail: cleanUrl(it.thumbnail || it.poster || ""),
}));
break;
}
default: {
const json = await requestApi(`${endpoint}?action=rank`);
const raw = Array.isArray(json) ? json : json.items || json.data || [];
items = raw.map((it) => ({
id: String(it.key || it.id || it.shortPlayId || it.dramaId || it.code || ""),
provider: p.name,
title: it.title || it.name || it.shortPlayName || "",
thumbnail: cleanUrl(it.cover || it.thumbnail || it.image || it.poster || it.shortPlayCover || it.icon || ""),
description: it.desc || it.description || it.intro || it.introduction || it.summary || "",
totalEpisodes: Number(it.episodeCount || it.totalEpisodes || it.total_episodes || it.chapters || it.episodes || 0),
tags: Array.isArray(it.tags) ? it.tags : Array.isArray(it.genres) ? it.genres : [],
}));
break;
}
}
} catch (err) {
throw new Error(`Gagal mengambil rank dari provider ${p.label}: ${err.message}`);
}
// Deduplikasi by ID
const seen = new Set();
return items.filter((it) => {
if (!it.id || seen.has(it.id)) return false;
seen.add(it.id);
return true;
});
}
/**
* 3. Pencarian drama berdasarkan judul / kata kunci
*/
async function search(query, provider) {
if (!query || typeof query !== "string") {
throw new Error("Parameter pencarian 'query' wajib diisi.");
}
const cleanQuery = query.trim().toLowerCase();
// Jika provider ditentukan
if (provider) {
const p = PROVIDERS[provider.toLowerCase()];
if (!p) throw new Error(`Provider "${provider}" tidak valid.`);
try {
if (p.name === "dotdrama") {
const all = await getRank("dotdrama");
return all.filter((d) => d.title.toLowerCase().includes(cleanQuery) || d.description?.toLowerCase().includes(cleanQuery));
}
const json = await requestApi(`${p.endpoint}?action=search&q=${encodeURIComponent(query)}`);
const raw = Array.isArray(json) ? json : json.items || json.data || [];
return raw.map((it) => ({
id: String(it.key || it.id || it.shortPlayId || it.dramaId || it.code || ""),
provider: p.name,
title: it.title || it.name || it.shortPlayName || "",
thumbnail: cleanUrl(it.cover || it.thumbnail || it.image || it.poster || it.shortPlayCover || it.icon || ""),
description: it.desc || it.description || it.intro || it.introduction || it.summary || "",
totalEpisodes: Number(it.episodeCount || it.totalEpisodes || it.total_episodes || it.chapters || it.episodes || 0),
}));
} catch (err) {
throw new Error(`Pencarian gagal pada ${p.label}: ${err.message}`);
}
}
// Multi-provider search (default ke top 5 provider cepat: freereels, netshort, melolo, dramabite, dotdrama)
const targetProviders = ["freereels", "melolo", "dramabite", "dotdrama", "netshort"];
const results = await Promise.allSettled(
targetProviders.map(async (prov) => {
return await search(query, prov);
})
);
const merged = [];
results.forEach((r) => {
if (r.status === "fulfilled" && Array.isArray(r.value)) {
merged.push(...r.value);
}
});
return merged;
}
/**
* 4. Mendapatkan detail drama dan seluruh episodenya
*/
async function getDetail(provider, dramaId) {
const p = PROVIDERS[provider.toLowerCase()];
if (!p) throw new Error(`Provider "${provider}" tidak valid.`);
if (!dramaId) throw new Error("Parameter dramaId wajib disertakan.");
const endpoint = p.endpoint;
let detail = null;
let episodes = [];
try {
switch (p.name) {
case "freereels": {
const json = await requestApi(`${endpoint}?action=detail&seriesKey=${encodeURIComponent(dramaId)}`);
detail = {
id: dramaId,
provider: p.name,
title: json.title || "",
thumbnail: cleanUrl(json.poster || json.cover || ""),
description: json.description || "",
totalEpisodes: Number(json.totalEpisodes || json.episodes?.length || 0),
};
episodes = (json.episodes || []).map((ep, idx) => ({
videoFakeId: ep.videoFakeId || `${dramaId}::${ep.id || idx + 1}`,
episodeNumber: ep.episodeNumber || idx + 1,
title: ep.title || `Episode ${ep.episodeNumber || idx + 1}`,
thumbnail: cleanUrl(ep.thumbnail || ""),
duration: ep.duration || undefined,
}));
break;
}
case "dotdrama": {
const json = await requestApi(`${endpoint}?action=detail&id=${encodeURIComponent(dramaId)}`);
detail = {
id: dramaId,
provider: p.name,
title: json.title || dramaId,
thumbnail: cleanUrl(json.cover || ""),
description: json.description || "",
totalEpisodes: Number(json.totalEpisodes || json.episodes?.length || 0),
};
episodes = (json.episodes || []).map((ep) => ({
videoFakeId: `${dramaId}::${ep.index}`,
episodeNumber: ep.index,
title: ep.name || `Episode ${ep.index}`,
directUrl: ep.originalUrl || ep.videoUrl || undefined,
quality: ep.quality || "auto",
}));
break;
}
case "netshort": {
const json = await requestApi(`${endpoint}?action=detail&id=${encodeURIComponent(dramaId)}`);
const data = json.data || {};
detail = {
id: dramaId,
provider: p.name,
title: data.title || dramaId,
thumbnail: cleanUrl(data.coverImgUrl || ""),
description: data.introduce || "",
tags: data.genre ? data.genre.split(", ") : [],
totalEpisodes: Number(data.totalOfEpisodes || data.episodes?.length || 0),
};
episodes = (data.episodes || []).map((ep) => ({
videoFakeId: ep.videoFakeId || `${dramaId}::${ep.id}`,
episodeNumber: ep.episode || 1,
title: ep.title || `Episode ${ep.episode}`,
thumbnail: cleanUrl(ep.cover || ""),
}));
break;
}
default: {
const json = await requestApi(`${endpoint}?action=detail&id=${encodeURIComponent(dramaId)}`);
detail = {
id: String(json.id || dramaId),
provider: p.name,
title: json.title || json.name || json.shortPlayName || dramaId,
thumbnail: cleanUrl(json.cover || json.thumbnail || json.poster || json.image || ""),
description: json.description || json.summary || json.intro || "",
totalEpisodes: Number(json.totalEpisodes || json.episodes?.length || 0),
tags: Array.isArray(json.tags) ? json.tags : Array.isArray(json.genres) ? json.genres : [],
};
episodes = (json.episodes || []).map((ep, idx) => ({
videoFakeId: ep.videoFakeId || `${dramaId}::${ep.episodeNo || ep.id || idx + 1}`,
episodeNumber: Number(ep.episodeNo || ep.episodeNumber || ep.index || idx + 1),
title: ep.title || `Episode ${ep.episodeNo || ep.episodeNumber || idx + 1}`,
thumbnail: cleanUrl(ep.thumbnail || ep.cover || ""),
duration: ep.duration || undefined,
}));
break;
}
}
} catch (err) {
throw new Error(`Gagal mengambil detail drama (${provider}/${dramaId}): ${err.message}`);
}
return { detail, episodes };
}
/**
* 5. Mendapatkan URL Streaming Video (HLS/m3u8/mp4) beserta Subtitle
*/
async function getStream(provider, videoFakeId) {
const p = PROVIDERS[provider.toLowerCase()];
if (!p) throw new Error(`Provider "${provider}" tidak valid.`);
if (!videoFakeId) throw new Error("Parameter videoFakeId wajib disertakan.");
const endpoint = p.endpoint;
try {
switch (p.name) {
case "dotdrama": {
const parts = videoFakeId.split("::");
const [dramaId, indexStr] = parts;
const json = await requestApi(`${endpoint}?action=detail&id=${encodeURIComponent(dramaId)}`);
const targetEp = (json.episodes || []).find((e) => e.index === parseInt(indexStr));
if (!targetEp) throw new Error("Episode tidak ditemukan pada drama ini.");
const videoUrl = targetEp.originalUrl || targetEp.videoUrl;
return {
provider: p.name,
videoFakeId,
url: cleanUrl(videoUrl),
quality: targetEp.quality || "auto",
subtitles: [],
};
}
case "freereels": {
const json = await requestApi(`${endpoint}?action=stream&videoFakeId=${encodeURIComponent(videoFakeId)}`);
if (!json.url) throw new Error("URL streaming tidak tersedia.");
return {
provider: p.name,
videoFakeId,
url: cleanUrl(json.url),
quality: json.quality || "H264",
subtitles: (json.subtitles || []).map((s) => ({
label: s.label,
lang: s.lang,
url: cleanUrl(s.url),
})),
};
}
case "netshort": {
const json = await requestApi(`${endpoint}?action=watch&id=${encodeURIComponent(videoFakeId)}`);
const data = json.data || {};
if (!data.videoUrl) throw new Error("Video URL NetShort tidak tersedia.");
return {
provider: p.name,
videoFakeId,
url: cleanUrl(data.videoUrl),
quality: data.quality || "auto",
subtitles: (data.subtitles || []).map((s) => ({
label: s.label || "Subtitle",
lang: s.lang || "und",
url: cleanUrl(s.url),
})),
};
}
case "stardusttv":
case "microdrama": {
const parts = videoFakeId.split("::");
if (parts.length >= 3) {
const direct = decodeURIComponent(parts.slice(2).join("::"));
return { provider: p.name, videoFakeId, url: direct, quality: "auto", subtitles: [] };
}
throw new Error("Format videoFakeId tidak valid untuk provider ini.");
}
default: {
// Melolo, MeloShort, StarShort, ShortSky, DramaBite, BiliTV, WeTV, Shortwave, ReelShort, Sereal, dll.
const parts = videoFakeId.split("::");
const [a, b] = parts;
const urlReq = `${endpoint}?action=episode_video&id=${encodeURIComponent(a)}&ep=${encodeURIComponent(b || 1)}`;
const json = await requestApi(urlReq);
const rawUrl = json.url || json.streams?.[0]?.url;
if (!rawUrl) throw new Error("URL streaming tidak ditemukan.");
return {
provider: p.name,
videoFakeId,
url: cleanUrl(rawUrl),
quality: json.quality || "auto",
codec: json.codec || json.encode,
subtitles: (json.subtitles || []).map((s) => ({
label: s.label || s.lang || "Subtitle",
lang: s.lang || "id",
url: cleanUrl(s.url),
})),
};
}
}
} catch (err) {
throw new Error(`Gagal mengambil link stream video: ${err.message}`);
}
}
/**
* 6. Scrape langsung dari URL nonton CUTAD
* Contoh: https://www.cutad.web.id/watch/dotdrama/anak-magangku-ternyata-istriku--2094673365253947393
*/
async function scrapeFromUrl(watchUrl) {
const match = watchUrl.match(/watch\/([a-zA-Z0-9_\-]+)\/([a-zA-Z0-9_\-]+)/);
if (!match) {
throw new Error("Format URL tidak valid. Contoh: https://www.cutad.web.id/watch/dotdrama/slug--id");
}
const provider = match[1].toLowerCase();
const slug = match[2];
// Ekstrak ID dari akhir slug (jika format: slug--id)
const idMatch = slug.match(/--([0-9a-zA-Z_\-]+)$/);
const dramaId = idMatch ? idMatch[1] : slug;
console.log(`[CUTAD] Memindai drama dari provider: ${provider}, ID: ${dramaId} ...`);
// 1. Coba ekstrak data langsung dari Server-Side Rendered (SSR) HTML
try {
const cookie = await getSession();
const pageRes = await fetch(watchUrl, {
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
Referer: BASE_URL + "/",
...(cookie ? { Cookie: cookie } : {}),
},
signal: AbortSignal.timeout(10000),
});
if (pageRes.ok) {
const html = await pageRes.text();
const detailMatch = html.match(/\\"initialDetail\\":(\{.*?\}(?=,\\"initialEpisodes))/);
const epsMatch = html.match(/\\"initialEpisodes\\":(\[\{.*?\}\](?=,\\"initialStream))/);
const streamMatch = html.match(/\\"initialStream\\":(\{.*?\}(?=,\"[a-zA-Z0-9_$]+\":|,\"\$|\]|\}))/);
if (detailMatch && epsMatch) {
const unescapeStr = (s) => s.replace(/\\"/g, '"').replace(/\\\\/g, "\\");
const rawDetail = JSON.parse(unescapeStr(detailMatch[1]));
const rawEpisodes = JSON.parse(unescapeStr(epsMatch[1]));
let firstEpisodeStream = null;
if (streamMatch) {
try {
const rawStream = JSON.parse(unescapeStr(streamMatch[1]));
if (rawStream && rawStream.url) {
firstEpisodeStream = {
provider,
videoFakeId: rawEpisodes[0]?.videoFakeId || `${dramaId}::1`,
url: cleanUrl(rawStream.url),
quality: rawStream.quality || "auto",
subtitles: (rawStream.subtitles || []).map((s) => ({
label: s.label || s.lang || "Subtitle",
lang: s.lang || "id",
url: cleanUrl(s.url),
})),
};
}
} catch {}
}
const episodes = rawEpisodes.map((ep, idx) => ({
videoFakeId: ep.videoFakeId || `${dramaId}::${ep.episodeNumber || idx + 1}`,
episodeNumber: ep.episodeNumber || idx + 1,
title: ep.title || `Episode ${ep.episodeNumber || idx + 1}`,
thumbnail: cleanUrl(ep.thumbnail || ""),
duration: ep.duration || undefined,
}));
return {
status: true,
provider,
dramaId,
detail: {
id: String(rawDetail.id || dramaId),
provider,
title: rawDetail.title || dramaId,
thumbnail: cleanUrl(rawDetail.thumbnail || rawDetail.cover || ""),
description: rawDetail.description || "",
totalEpisodes: Number(rawDetail.totalEpisodes || episodes.length),
tags: Array.isArray(rawDetail.tags) ? rawDetail.tags : [],
},
totalEpisodes: episodes.length,
episodes,
firstEpisodeStream,
};
}
}
} catch (err) {
// Fallback ke pemanggilan API biasa
}
// 2. Fallback via API internal
const { detail, episodes } = await getDetail(provider, dramaId);
let firstEpisodeStream = null;
if (episodes.length > 0) {
try {
firstEpisodeStream = await getStream(provider, episodes[0].videoFakeId);
} catch {}
}
return {
status: true,
provider,
dramaId,
detail,
totalEpisodes: episodes.length,
episodes,
firstEpisodeStream,
};
}
if (typeof module !== "undefined" && module.exports) {
module.exports = {
PROVIDERS,
getProviders,
getRank,
search,
getDetail,
getStream,
scrapeFromUrl,
};
}
// CLI Execution Helper
if (require.main === module) {
(async () => {
const args = process.argv.slice(2);
const command = args[0];
if (!command || command === "--help" || command === "-h") {
console.log(`
🎬 CUTAD Drama & Donghua Scraper CLI
Author: Vamz Spectre (VamxAPI)
Penggunaan:
node cutad.js --providers Daftar semua 20 provider yang didukung
node cutad.js --rank <provider> Lihat drama trending/populer (default: freereels)
node cutad.js --search <keyword> [provider] Cari drama berdasarkan judul
node cutad.js --detail <provider> <id> Lihat detail drama & daftar episode
node cutad.js --stream <provider> <fakeId> Ambil link streaming video m3u8 & subtitle
node cutad.js <watch_url> Scrape langsung dari link halaman web CUTAD
Contoh:
node cutad.js --rank freereels
node cutad.js --search "CEO" freereels
node cutad.js "https://www.cutad.web.id/watch/dotdrama/anak-magangku-ternyata-istriku--2094673365253947393"
`);
process.exit(0);
}
if (command === "--providers") {
console.log("Daftar Provider CUTAD:");
getProviders().forEach((p, idx) => {
console.log(` ${idx + 1}. [${p.name}] ${p.label} - ${p.desc}`);
});
process.exit(0);
}
if (command === "--rank") {
const prov = args[1] || "freereels";
console.log(`[CUTAD] Mengambil rank dari provider: ${prov} ...`);
getRank(prov)
.then((items) => {
console.log(`Ditemukan ${items.length} drama populer:`);
items.slice(0, 10).forEach((it, idx) => {
console.log(`\n#${idx + 1} [ID: ${it.id}] ${it.title}`);
if (it.totalEpisodes) console.log(` Episode: ${it.totalEpisodes}`);
if (it.thumbnail) console.log(` Cover : ${it.thumbnail}`);
});
})
.catch((err) => console.error("[ERROR]", err.message));
return;
}
if (command === "--search") {
const query = args[1];
const prov = args[2];
if (!query) {
console.log("Masukkan keyword pencarian: node cutad.js --search <keyword>");
process.exit(1);
}
console.log(`[CUTAD] Mencari "${query}" ${prov ? `di ${prov}` : "di semua provider"} ...`);
search(query, prov)
.then((items) => {
console.log(`Ditemukan ${items.length} hasil:`);
items.slice(0, 10).forEach((it, idx) => {
console.log(`\n#${idx + 1} [${it.provider.toUpperCase()}] [ID: ${it.id}] ${it.title}`);
if (it.totalEpisodes) console.log(` Episode: ${it.totalEpisodes}`);
if (it.thumbnail) console.log(` Cover : ${it.thumbnail}`);
});
})
.catch((err) => console.error("[ERROR]", err.message));
return;
}
if (command === "--detail") {
const prov = args[1];
const id = args[2];
if (!prov || !id) {
console.log("Usage: node cutad.js --detail <provider> <id>");
process.exit(1);
}
console.log(`[CUTAD] Mengambil detail ${prov}/${id} ...`);
getDetail(prov, id)
.then((res) => {
console.log("\n--- DETAIL DRAMA ---");
console.log("Judul :", res.detail.title);
console.log("Episode :", res.episodes.length);
console.log("Cover :", res.detail.thumbnail);
console.log("Sinopsis:", res.detail.description?.slice(0, 150) + "...");
console.log("\nContoh 5 Episode Pertama:");
res.episodes.slice(0, 5).forEach((ep) => {
console.log(` - [${ep.episodeNumber}] ${ep.title} (FakeId: ${ep.videoFakeId})`);
});
})
.catch((err) => console.error("[ERROR]", err.message));
return;
}
if (command === "--stream") {
const prov = args[1];
const fakeId = args[2];
if (!prov || !fakeId) {
console.log("Usage: node cutad.js --stream <provider> <videoFakeId>");
process.exit(1);
}
console.log(`[CUTAD] Mengambil stream ${prov} untuk fakeId: ${fakeId} ...`);
getStream(prov, fakeId)
.then((st) => {
console.log("\n--- STREAM VIDEO ---");
console.log("URL Video :", st.url);
console.log("Quality :", st.quality);
if (st.subtitles?.length) {
console.log("Subtitles :");
st.subtitles.forEach((s) => console.log(` - [${s.lang || s.label}] ${s.url}`));
}
})
.catch((err) => console.error("[ERROR]", err.message));
return;
}
// Jika input URL watch
if (command.startsWith("http")) {
scrapeFromUrl(command)
.then((res) => {
console.log("\n--- HASIL SCRAPE URL WATCH ---");
console.log("Provider :", res.provider);
console.log("Judul :", res.detail?.title);
console.log("Total Episode:", res.totalEpisodes);
console.log("Cover :", res.detail?.thumbnail);
if (res.firstEpisodeStream) {
console.log("\nStream Episode 1:");
console.log(" Video URL :", res.firstEpisodeStream.url);
console.log(" Kualitas :", res.firstEpisodeStream.quality);
if (res.firstEpisodeStream.subtitles?.length) {
console.log(" Subtitles :");
res.firstEpisodeStream.subtitles.forEach((s) => console.log(` - [${s.label || s.lang}] ${s.url}`));
}
}
})
.catch((err) => console.error("[ERROR]", err.message));
}
})();
}