Pencarian Snippet

Ditemukan 1 snippet.

Anime JavaScript

Otakudesu

Mencari anime Otakudesu

/** * Judul : Otakudesu Scraper * Base URL : https://otakudesu.blog * Author : Cx99 - t.me/exploit99 * Deskripsi : Mencari anime Otakudesu * Channel : https://whatsapp.com/channel/0029VbCSF8sA89MopCVOYW06 */ const fs = require('fs'); const ORIGIN = 'https://otakudesu.blog'; const USER_AGENT = 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Mobile Safari/537.36'; const CREATOR = 't.me/luyatiem'; let dumped = false; const decode = s => s .replace(/&#(\d+);/g, (_, n) => String.fromCharCode(Number(n))) .replace(/&#x([0-9a-f]+);/gi, (_, n) => String.fromCharCode(parseInt(n, 16))) .replace(/&quot;/g, '"').replace(/&#039;|&apos;/g, "'") .replace(/&lt;/g, '<').replace(/&gt;/g, '>') .replace(/&nbsp;/g, ' ').replace(/&amp;/g, '&'); const clean = s => decode((s || '').replace(/<[^>]+>/g, ' ')).replace(/\s+/g, ' ').trim(); const pick = (s, re) => s.match(re)?.[1] || ''; function dump(name, html) { if (dumped) return; dumped = true; fs.writeFileSync(name, html); return name; } function parseCards(html, type) { return html.split(/<li><div class=['"]detpost['"]>/).slice(1).map(chunk => { const epz = clean(pick(chunk, /<div class=['"]epz['"]>([\s\S]*?)<\/div>/)); const tipe = clean(pick(chunk, /<div class=['"]epztipe['"]>([\s\S]*?)<\/div>/)); const item = { title: clean(pick(chunk, /<h2 class="jdlflm">([\s\S]*?)<\/h2>/)), url: pick(chunk, /<a href="([^"]+)"/), thumb: pick(chunk, /<img[^>]+src="([^"]+)"/), date: clean(pick(chunk, /<div class="newnime">([\s\S]*?)<\/div>/)) }; return type === 'ongoing' ? { ...item, episode: epz, day: tipe } : { ...item, episodes: epz, score: tipe }; }); } function parseHome(html) { const idx = html.indexOf('Complete Anime</h1>'); return { ongoing: parseCards(idx >= 0 ? html.slice(0, idx) : html, 'ongoing'), complete: parseCards(idx >= 0 ? html.slice(idx) : '', 'complete') }; } function parseSearch(html) { return [...html.matchAll(/<li[^>]*>\s*<img[^>]+src="([^"]+)"[^>]*>\s*<h2><a href="([^"]+)"[^>]*>([\s\S]*?)<\/a><\/h2>([\s\S]*?)<\/li>/g)].map(m => { const info = {}; for (const s of m[4].matchAll(/<div class="set"><b>([^<]+)<\/b>\s*:?\s*([\s\S]*?)<\/div>/g)) { info[clean(s[1]).toLowerCase()] = clean(s[2]).replace(/^:\s*/, ''); } return { title: clean(m[3]), url: m[2], thumb: m[1], ...info }; }); } function parseDetail(html) { const info = {}; for (const m of html.matchAll(/<p[^>]*>\s*<span[^>]*>\s*<b>([^<]+)<\/b>\s*:\s*([\s\S]*?)<\/span>\s*<\/p>/g)) { info[clean(m[1]).toLowerCase()] = clean(m[2]); } const start = html.search(/class=["']episodelist["']/); const area = start >= 0 ? html.slice(start) : html; const seen = new Set(), episodes = []; for (const m of area.matchAll(/<a[^>]+href="([^"]*\/episode\/[^"]*)"[^>]*>([\s\S]*?)<\/a>(?:\s*<\/span>\s*<span[^>]*>([\s\S]*?)<\/span>)?/g)) { const title = clean(m[2]); if (!title || seen.has(m[1])) continue; seen.add(m[1]); episodes.push({ title, url: m[1], date: clean(m[3]) }); } const num = e => e.title.match(/episode\s*(\d+)/i)?.[1] * 1 || null; episodes.sort((a, b) => { const na = num(a), nb = num(b); return na !== null && nb !== null ? na - nb : 0; }); const imgTag = pick(html, /(<img[^>]+wp-post-image[^>]*>)/); return { thumb: pick(html, /<meta property="og:image" content="([^"]+)"/) || pick(imgTag, /src="([^"]+)"/), ...info, sinopsis: clean(pick(html, /<div class="sinopc">([\s\S]*?)<\/div>/)) || decode(pick(html, /<meta property="og:description" content="([^"]*)"/)), batch: pick(html, /href="([^"]*\/batch\/[^"]*)"/), episodes }; } function parseEpisode(html) { const start = html.search(/class=["']download["']/); const part = start >= 0 ? html.slice(start) : html; const downloads = [...part.matchAll(/<li[^>]*>\s*<strong[^>]*>([\s\S]*?)<\/strong>([\s\S]*?)<\/li>/g)] .map(m => ({ quality: clean(m[1]), size: clean(pick(m[2], /<i[^>]*>([\s\S]*?)<\/i>/)), links: [...m[2].matchAll(/<a[^>]+href="([^"]+)"[^>]*>([\s\S]*?)<\/a>/g)] .map(a => ({ host: clean(a[2]), url: decode(a[1]) })) })) .filter(x => x.links.length); const links = []; if (!downloads.length) { const seen = new Set(); for (const a of html.matchAll(/<a[^>]+href="([^"]+)"[^>]*>([\s\S]*?)<\/a>/g)) { const url = decode(a[1]); if (seen.has(url)) continue; seen.add(url); links.push({ host: clean(a[2]), url }); } } return { title: clean(pick(html, /<h1[^>]*>([\s\S]*?)<\/h1>/)), stream: pick(html, /<iframe[^>]+src="([^"]+)"/), downloads, links }; } async function getHtml(url) { const res = await fetch(url, { headers: { 'User-Agent': USER_AGENT, Accept: 'text/html,application/xhtml+xml', 'Accept-Language': 'id-ID,id;q=0.9,en;q=0.8', Referer: `${ORIGIN}/` } }); if (!res.ok) throw new Error(`HTTP ${res.status}`); return await res.text(); } async function pool(items, limit, fn) { const out = new Array(items.length); let i = 0; await Promise.all(Array.from({ length: Math.min(limit, items.length) }, async () => { while (i < items.length) { const idx = i++; try { out[idx] = await fn(items[idx]); } catch (err) { out[idx] = { ...items[idx], error: err.message }; } } })); return out; } async function episodeLinks(url) { const html = await getHtml(url); const page = parseEpisode(html); let debug; if (!page.downloads.length && !page.links.length) { debug = dump(`episode_debug_${pick(url, /\/episode\/([^/]+)/) || 'x'}.html`, html); } return { title: page.title, stream: page.stream, downloads: page.downloads, links: page.links, debug }; } async function animeLinks(url) { const html = await getHtml(url); const detail = parseDetail(html); let debug; if (!detail.episodes.length) debug = dump('detail_debug.html', html); const episodes = await pool(detail.episodes, 3, async ep => { const r = await episodeLinks(ep.url); const out = { title: ep.title, date: ep.date, url: ep.url, stream: r.stream, downloads: r.downloads }; if (r.links.length) out.links = r.links; if (r.debug) out.debug = r.debug; return out; }); return { title: detail.judul, status: detail.status, skor: detail.skor, genre: detail.genre, thumb: detail.thumb, sinopsis: detail.sinopsis, batch: detail.batch || undefined, debug, episodes }; } async function otakudesu(action, query = '') { action = String(action || '').toLowerCase(); query = String(query || '').trim(); switch (action) { case 'home': return parseHome(await getHtml(`${ORIGIN}/`)); case 'search': if (!query) throw new Error('Masukkan judul anime!'); return parseSearch(await getHtml(`${ORIGIN}/?s=${encodeURIComponent(query)}&post_type=anime`)); case 'detail': if (!query) throw new Error('Masukkan URL detail anime!'); return await animeLinks(query); case 'episode': if (!query) throw new Error('Masukkan URL episode!'); return await episodeLinks(query); case 'ongoing': return parseCards(await getHtml(`${ORIGIN}/ongoing-anime/`), 'ongoing'); case 'complete': return parseCards(await getHtml(`${ORIGIN}/complete-anime/`), 'complete'); default: throw new Error(`Command '${action}' tidak ditemukan.`); } } module.exports = { otakudesu, episodeLinks, animeLinks }; (async () => { const { otakudesu } = require('./otakudesu'); try { const result = await otakudesu('search', 'naruto'); console.log(JSON.stringify({ creator: 't.me/luyatiem', status: true, command: 'search', data: result }, null, 2)); } catch (error) { console.log(JSON.stringify({ creator: 't.me/luyatiem', status: false, error: error.message }, null, 2)); } })();
Cx99 • 7 views
Home Search Request Owner Login