scraperjavascript145
Aniwave Anime Scraper (Search, Episode List & Direct HLS Stream Extractor)
Scraper Aniwave (aniwaves.tv): Mencari anime, mengambil detail dan daftar episode lengkap, serta mengekstrak server streaming (Vidplay, BYFMS, DGHG), embed URL, dan direct HLS (.m3u8) playlist HD lengkap dengan subtitle/thumbnail sprite tracks dan skip intro/outro timestamp.
Vamz Spectre18 Nov 2026379 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/aniwaves" -o aniwaves.js
# 2. Jalankan script
node aniwaves.js
Dependencies npm yang Dibutuhkan:
npm install axios, cheerioPanduan Penggunaan:
// Download Script: curl -sL "https://code.vamxapi.my.id/snippet/raw/aniwaves" -o aniwaves.js // 1. Search Anime: node aniwaves.js search "naruto" // 2. Detail Anime & Seluruh Episode: node aniwaves.js detail "naruto-76396" // 3. Stream Episode (Server, Embed & Direct .m3u8): node aniwaves.js stream "76396" 1 "sub"
aniwaves.js(379 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
/**
* Aniwave Scraper (aniwaves.tv)
* Author: Vamz Spectre / VamxAPI
*
* Download Script:
* curl -sL "https://code.vamxapi.my.id/snippet/raw/aniwaves" -o aniwaves.js
*
* Usage:
* node aniwaves.js search "naruto"
* node aniwaves.js detail "naruto-76396"
* node aniwaves.js stream "76396" 1 "sub"
*/
const axios = require('axios');
const cheerio = require('cheerio');
const BASE_URL = 'https://aniwaves.tv';
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}/`,
'X-Requested-With': 'XMLHttpRequest',
'Accept': 'application/json, text/html, */*'
};
const client = axios.create({
baseURL: BASE_URL,
headers: HEADERS,
timeout: 15000
});
/**
* 1. Search anime by keyword
*/
async function searchAnime(keyword, page = 1) {
if (!keyword) throw new Error('Keyword is required');
try {
const res = await client.get(`/filter?keyword=${encodeURIComponent(keyword)}&page=${page}`);
const $ = cheerio.load(res.data);
const results = [];
$('#list-items .item').each((_, el) => {
const item = $(el);
const linkEl = item.find('.name.d-title');
const href = linkEl.attr('href') || item.find('a').first().attr('href') || '';
const slug = href.replace(/^\/watch\//, '');
const idMatch = slug.match(/-(\d+)$/);
const id = idMatch ? idMatch[1] : null;
const title = linkEl.text().trim();
const japaneseTitle = linkEl.attr('data-jp') || '';
const poster = item.find('.poster img').attr('src') || '';
const type = item.find('.poster .meta .right').text().trim() || item.find('.m-item:contains("TV"), .m-item:contains("Movie")').last().text().trim();
const sub = item.find('.ep-status.sub span').text().trim() || item.find('.m-item:has(.fa-closed-captioning) span').text().trim() || '0';
const dub = item.find('.ep-status.dub span').text().trim() || item.find('.m-item:has(.fa-microphone) span').text().trim() || '0';
const totalEp = item.find('.ep-status.total span').text().trim() || '0';
const score = item.find('.m-item.rated span').text().trim() || item.find('.score').text().trim() || '-';
const genres = [];
item.find('.genre a').each((_, g) => {
genres.push($(g).text().trim());
});
if (title && href) {
results.push({
id,
title,
japaneseTitle,
slug,
url: `${BASE_URL}${href}`,
poster,
type,
episodes: {
sub: parseInt(sub, 10) || 0,
dub: parseInt(dub, 10) || 0,
total: parseInt(totalEp, 10) || 0
},
score,
genres
});
}
});
return {
status: true,
query: keyword,
page: parseInt(page, 10),
totalResults: results.length,
results
};
} catch (err) {
return {
status: false,
error: err.message
};
}
}
/**
* 2. Get Anime Detail and Episode List
*/
async function getAnimeDetail(slugOrId) {
if (!slugOrId) throw new Error('Anime slug or ID is required');
try {
let watchUrl = '';
let animeId = '';
if (/^\d+$/.test(slugOrId)) {
animeId = slugOrId;
watchUrl = `/watch/${animeId}`;
} else {
watchUrl = `/watch/${slugOrId}`;
const idMatch = slugOrId.match(/-(\d+)$/);
if (idMatch) animeId = idMatch[1];
}
const pageRes = await client.get(watchUrl);
const $ = cheerio.load(pageRes.data);
if (!animeId) {
animeId = $('#watch-main').attr('data-id') || '';
}
const title = $('#w-info .title').text().trim();
const japaneseTitle = $('#w-info .title').attr('data-jp') || '';
const poster = $('#w-info .poster img').attr('src') || '';
const synopsis = $('#w-info .synopsis .content').text().trim();
// Extract metadata
const metadata = {};
$('#w-info .bmeta .meta > div').each((_, el) => {
const text = $(el).text().trim();
const parts = text.split(':');
if (parts.length >= 2) {
const key = parts[0].trim().toLowerCase().replace(/\s+/g, '_');
const val = parts.slice(1).join(':').trim();
metadata[key] = val;
}
});
const genres = [];
$('#w-info .bmeta a[href^="/genre/"]').each((_, el) => {
genres.push($(el).text().trim());
});
// Fetch episodes list via AJAX
let episodes = [];
if (animeId) {
const epRes = await client.get(`/ajax/episode/list/${animeId}`);
if (epRes.data && epRes.data.status === 200 && epRes.data.result) {
const $ep = cheerio.load(epRes.data.result);
$ep('.episodes .ep-range li').each((_, el) => {
const li = $ep(el);
const a = li.find('a');
const num = a.attr('data-num') || a.text().trim();
const epSlug = a.attr('data-slug') || num;
const href = a.attr('href') || '';
const fullTitleAttr = li.attr('title') || '';
let epTitle = '';
const titleMatch = fullTitleAttr.match(/-\s*(.+)$/);
if (titleMatch) epTitle = titleMatch[1].trim();
episodes.push({
episode: parseInt(num, 10) || num,
slug: epSlug,
title: epTitle || `Episode ${num}`,
japaneseTitle: li.attr('data-jp') || '',
durationSeconds: parseInt(a.attr('data-duration'), 10) || 0,
isFiller: a.attr('data-filler') === '1',
hasSub: a.attr('data-sub') === '1',
hasDub: a.attr('data-dub') === '1',
url: href ? `${BASE_URL}${href}` : ''
});
});
}
}
return {
status: true,
data: {
id: animeId,
title,
japaneseTitle,
poster,
synopsis,
genres,
metadata,
totalEpisodes: episodes.length,
episodes
}
};
} catch (err) {
return {
status: false,
error: err.message
};
}
}
/**
* 3. Extract stream source & direct m3u8 playlist
*/
async function getStreamSource(slugOrId, episodeNum = 1, preferredServer = 'sub') {
try {
let animeId = slugOrId;
if (!/^\d+$/.test(slugOrId)) {
const idMatch = slugOrId.match(/-(\d+)$/);
if (idMatch) {
animeId = idMatch[1];
} else {
const detail = await getAnimeDetail(slugOrId);
if (detail.status && detail.data.id) {
animeId = detail.data.id;
} else {
throw new Error('Unable to resolve anime ID');
}
}
}
// 1. Get servers list
const serverUrl = `/ajax/server/list?servers=${encodeURIComponent(animeId)}&eps=${episodeNum}`;
const serverRes = await client.get(serverUrl, {
headers: {
Referer: `${BASE_URL}/watch/${slugOrId}/ep-${episodeNum}`
}
});
if (!serverRes.data || serverRes.data.status !== 200 || !serverRes.data.result) {
throw new Error('Failed to retrieve servers list: ' + (serverRes.data?.message || 'Empty response'));
}
const $s = cheerio.load(serverRes.data.result);
const servers = {
sub: [],
dub: []
};
$s('.servers .type').each((_, typeEl) => {
const type = $s(typeEl).attr('data-type'); // 'sub' or 'dub'
if (!servers[type]) servers[type] = [];
$s(typeEl).find('ul li').each((_, liEl) => {
const li = $s(liEl);
servers[type].push({
name: li.text().trim(),
serverId: li.attr('data-sv-id'),
linkId: li.attr('data-link-id')
});
});
});
// Pick server list based on preferredServer (default: sub, fallback: dub)
const activeList = (servers[preferredServer] && servers[preferredServer].length > 0)
? servers[preferredServer]
: (servers.sub.length > 0 ? servers.sub : servers.dub);
if (activeList.length === 0) {
throw new Error('No available streaming servers found for this episode');
}
// Prefer Vidplay (data-sv-id="4") for direct m3u8 extraction
let chosenServer = activeList.find(s => s.serverId === '4') || activeList[0];
// 2. Call ajax/sources to get embed URL
const sourcesRes = await client.get(`/ajax/sources?id=${encodeURIComponent(chosenServer.linkId)}&asi=0&autoPlay=0`, {
headers: {
Referer: `${BASE_URL}/watch/${slugOrId}/ep-${episodeNum}`
}
});
if (!sourcesRes.data || sourcesRes.data.status !== 200 || !sourcesRes.data.result?.url) {
throw new Error('Failed to get source embed URL');
}
const embedUrl = sourcesRes.data.result.url;
let streamDetails = {
server: chosenServer.name,
serverId: chosenServer.serverId,
embedUrl: embedUrl,
skipData: sourcesRes.data.result.skip_data || null,
directStream: null
};
// 3. If embed is play.vhscdn.to (Vidplay), resolve direct m3u8 playlist!
if (embedUrl.includes('vhscdn.to/embed-1/')) {
try {
const embedRes = await axios.get(embedUrl, {
headers: {
'User-Agent': HEADERS['User-Agent'],
'Referer': `${BASE_URL}/`
},
timeout: 10000
});
const $emb = cheerio.load(embedRes.data);
const screenDiv = $emb('#screen');
const sourceId = screenDiv.attr('data-id') || embedUrl.split('/embed-1/')[1]?.split('?')[0];
if (sourceId) {
const directRes = await axios.get(`https://play.vhscdn.to/embed-1/getSources?id=${encodeURIComponent(sourceId)}`, {
headers: {
'User-Agent': HEADERS['User-Agent'],
'Referer': embedUrl,
'Accept': 'application/json, text/plain, */*',
'X-Requested-With': 'XMLHttpRequest'
},
timeout: 10000
});
if (directRes.data && directRes.data.sources) {
streamDetails.directStream = {
hlsUrl: directRes.data.sources,
tracks: directRes.data.tracks || [],
intro: directRes.data.intro || null,
outro: directRes.data.outro || null,
headers: {
'Referer': 'https://play.vhscdn.to/',
'User-Agent': HEADERS['User-Agent']
}
};
}
}
} catch (err) {
streamDetails.directStreamError = err.message;
}
}
return {
status: true,
animeId,
episode: parseInt(episodeNum, 10),
type: preferredServer,
availableServers: servers,
stream: streamDetails
};
} catch (err) {
return {
status: false,
error: err.message
};
}
}
// Module exports
module.exports = {
searchAnime,
getAnimeDetail,
getStreamSource
};
// Real CLI Runner
if (require.main === module) {
(async () => {
const action = process.argv[2] || 'search';
const arg1 = process.argv[3] || 'naruto';
const arg2 = process.argv[4] || 1;
const arg3 = process.argv[5] || 'sub';
let result;
if (action === 'search') {
result = await searchAnime(arg1, arg2);
} else if (action === 'detail') {
result = await getAnimeDetail(arg1);
} else if (action === 'stream') {
result = await getStreamSource(arg1, arg2, arg3);
} else {
console.log(JSON.stringify({
error: 'Invalid action. Usage: node aniwaves.js [search|detail|stream] <args>'
}, null, 2));
process.exit(1);
}
console.log(JSON.stringify(result, null, 2));
})();
}