/** * OtakuDesu Scraper Engine (CLI & Module) * Author: Vamz Spectre / VamxAPI * Website: https://vamxapi.my.id * Channel: https://whatsapp.com/channel/0029Vb8n36OGE56uvRAq4y3y */ const axios = require('axios'); const cheerio = require('cheerio'); // OtakuDesu Base URL const BASE_URL = 'https://otakudesu.blog'; const defaultHeaders = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8', 'Accept-Language': 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7', 'Referer': BASE_URL + '/', }; /** * Helper request HTTP */ async function getHtml(url) { try { const { data } = await axios.get(url, { headers: defaultHeaders, timeout: 15000, }); return data; } catch (err) { if (err.response && err.response.data) return err.response.data; throw new Error('Gagal mengakses OtakuDesu: ' + err.message); } } /** * 1. Ambil daftar Anime Ongoing (Terbaru rilis) */ async function getOngoingAnime(page = 1) { const url = page > 1 ? BASE_URL + '/ongoing-anime/page/' + page + '/' : BASE_URL + '/ongoing-anime/'; const html = await getHtml(url); const $ = cheerio.load(html); const items = []; $('.venz ul li').each((_, el) => { const title = $(el).find('h2.jdlflm').text().trim(); const episode = $(el).find('.epz').text().trim(); const day = $(el).find('.epztipe').text().trim(); const date = $(el).find('.newnime').text().trim(); const link = $(el).find('.thumb a').attr('href') || ''; const poster = $(el).find('.thumb img').attr('src') || ''; const slugMatch = link.match(/\/anime\/([^\/]+)/); const slug = slugMatch ? slugMatch[1] : link.split('/').filter(Boolean).pop(); if (title && link) { items.push({ title, slug, episode, release_day: day, release_date: date, poster, url: link, }); } }); return { status: true, page: Number(page), total: items.length, items, }; } /** * 2. Cari Anime berdasarkan Judul / Keyword * @param {string} query */ async function searchAnime(query) { if (!query || !query.trim()) throw new Error('Query pencarian anime wajib diisi!'); const cleanQ = query.trim(); const url = BASE_URL + '/?s=' + encodeURIComponent(cleanQ) + '&post_type=anime'; const html = await getHtml(url); const $ = cheerio.load(html); const items = []; $('.chlist li, ul.chlist li').each((_, el) => { const titleEl = $(el).find('h2 a, h2'); const title = titleEl.text().trim(); const link = $(el).find('h2 a').attr('href') || $(el).find('a').attr('href') || ''; const poster = $(el).find('img').attr('src') || ''; const genres = []; $(el).find('.set a, .genre a').each((_, g) => { genres.push($(g).text().trim()); }); const status = $(el).find('.set:contains("Status")').text().replace(/Status\s*:\s*/i, '').trim(); const rating = $(el).find('.set:contains("Rating")').text().replace(/Rating\s*:\s*/i, '').trim(); const slugMatch = link.match(/\/anime\/([^\/]+)/); const slug = slugMatch ? slugMatch[1] : link.split('/').filter(Boolean).pop(); if (title && link) { items.push({ title, slug, status: status || null, rating: rating || null, genres: genres.length > 0 ? genres : null, poster: poster || null, url: link, }); } }); return { status: true, query: cleanQ, total: items.length, items, }; } /** * 3. Dapatkan Detail Anime Lengkap & Daftar Episode * @param {string} slugOrUrl */ async function getAnimeDetail(slugOrUrl) { if (!slugOrUrl) throw new Error('Slug anime wajib disertakan!'); const url = slugOrUrl.startsWith('http') ? slugOrUrl : BASE_URL + '/anime/' + slugOrUrl.replace(/^\/+|\/+$/g, '') + '/'; const html = await getHtml(url); const $ = cheerio.load(html); const title = $('.infozin .infozingle p:contains("Judul")').text().replace(/Judul\s*:\s*/i, '').trim() || $('h1.jdlflm').text().trim(); const japanese = $('.infozin .infozingle p:contains("Japanese")').text().replace(/Japanese\s*:\s*/i, '').trim(); const score = $('.infozin .infozingle p:contains("Skor")').text().replace(/Skor\s*:\s*/i, '').trim(); const producer = $('.infozin .infozingle p:contains("Produser")').text().replace(/Produser\s*:\s*/i, '').trim(); const type = $('.infozin .infozingle p:contains("Tipe")').text().replace(/Tipe\s*:\s*/i, '').trim(); const status = $('.infozin .infozingle p:contains("Status")').text().replace(/Status\s*:\s*/i, '').trim(); const totalEp = $('.infozin .infozingle p:contains("Total Episode")').text().replace(/Total Episode\s*:\s*/i, '').trim(); const duration = $('.infozin .infozingle p:contains("Durasi")').text().replace(/Durasi\s*:\s*/i, '').trim(); const releaseDate = $('.infozin .infozingle p:contains("Tanggal Rilis")').text().replace(/Tanggal Rilis\s*:\s*/i, '').trim(); const studio = $('.infozin .infozingle p:contains("Studio")').text().replace(/Studio\s*:\s*/i, '').trim(); const poster = $('.fotoanime img').attr('src') || $('.thumb img').attr('src') || ''; const genres = []; $('.infozin .infozingle p:contains("Genre") a').each((_, g) => { genres.push($(g).text().trim()); }); const sinopsis = $('.sinopc p').map((_, p) => $(p).text().trim()).get().join('\n') || $('.sinopc').text().trim(); const episodes = []; $('.episodelist ul li').each((_, el) => { const epTitle = $(el).find('a').text().trim(); const epLink = $(el).find('a').attr('href') || ''; const epDate = $(el).find('.zeebr').text().trim(); const epSlugMatch = epLink.match(/\/episode\/([^\/]+)/); const epSlug = epSlugMatch ? epSlugMatch[1] : epLink.split('/').filter(Boolean).pop(); if (epTitle && epLink) { episodes.push({ title: epTitle, slug: epSlug, release_date: epDate || null, url: epLink, }); } }); return { status: true, title: title || 'OtakuDesu Anime', japanese_title: japanese || null, score: score || null, type: type || 'TV', status: status || 'Unknown', total_episodes: totalEp || null, duration: duration || null, release_date: releaseDate || null, studio: studio || null, producer: producer || null, genres, poster, sinopsis, episodes_count: episodes.length, episodes, }; } /** * 4. Parse Link Download & Stream Episode Anime * @param {string} slugOrUrl */ async function getEpisodeDownload(slugOrUrl) { if (!slugOrUrl) throw new Error('Slug episode wajib disertakan!'); const url = slugOrUrl.startsWith('http') ? slugOrUrl : BASE_URL + '/episode/' + slugOrUrl.replace(/^\/+|\/+$/g, '') + '/'; const html = await getHtml(url); const $ = cheerio.load(html); const title = $('.posttl').text().trim() || $('h1').text().trim(); const streamIframe = $('#embed_holder iframe').attr('src') || $('.responsive-embed-stream iframe').attr('src') || ''; const downloads = []; $('.download ul li').each((_, li) => { const qualityText = $(li).find('strong').text().trim(); const size = $(li).find('i').text().trim(); const links = []; $(li).find('a').each((_, a) => { links.push({ server: $(a).text().trim(), url: $(a).attr('href'), }); }); if (links.length > 0) { downloads.push({ quality: qualityText, size: size || null, links, }); } }); return { status: true, title, stream_url: streamIframe || null, downloads, }; } if (typeof module !== "undefined" && module.exports) { module.exports = { getOngoingAnime, searchAnime, getAnimeDetail, getEpisodeDownload, }; } // Mode CLI Langsung (Interactive & Parameter Checker) if (require.main === module) { const args = process.argv.slice(2); const query = args.join(' ').trim(); if (!query) { console.log(` ============================================================= OTAKUDESU ANIME SCRAPER ENGINE (CLI) ============================================================= ❌ Error: Parameter perintah atau judul anime tidak boleh kosong! 📖 CARA PENGGUNAAN LENGKAP: node otakudesu-anime.js node otakudesu-anime.js --ongoing (Cek rilis anime ongoing terbaru) node otakudesu-anime.js --detail (Info detail, sinopsis & episode) node otakudesu-anime.js --download (Ambil direct download link) 📌 CONTOH PENGGUNAAN: node otakudesu-anime.js "Naruto" node otakudesu-anime.js "Solo Leveling" node otakudesu-anime.js --ongoing node otakudesu-anime.js --detail "sl-season-2-sub-indo" node otakudesu-anime.js --download "sl-season-2-episode-1-sub-indo" 💡 INTEGRASI MODULAR (Node.js / Express / Baileys): const { searchAnime, getAnimeDetail, getEpisodeDownload, getOngoingAnime } = require("./otakudesu-anime"); const anime = await searchAnime("One Piece"); console.log(anime); ============================================================= `); process.exit(1); } (async () => { try { console.log('⏳ Sedang memproses OtakuDesu...'); if (query === '--ongoing' || query === '-o') { const res = await getOngoingAnime(1); console.log(JSON.stringify(res, null, 2)); } else if (query.startsWith('--detail ') || query.startsWith('-d ')) { const slug = query.replace(/^(--detail|-d)\s+/, '').trim(); const res = await getAnimeDetail(slug); console.log(JSON.stringify(res, null, 2)); } else if (query.startsWith('--download ') || query.startsWith('-dl ')) { const slug = query.replace(/^(--download|-dl)\s+/, '').trim(); const res = await getEpisodeDownload(slug); console.log(JSON.stringify(res, null, 2)); } else { const res = await searchAnime(query); console.log(JSON.stringify(res, null, 2)); } } catch (err) { console.error('❌ Terjadi Kesalahan:', err.message); } })(); }