/** * Nimegami.id Scraper & Direct Video Stream Extractor * Author: Vamz Spectre / VamxAPI * Target: https://nimegami.id * * Download: * curl -sL "https://code.vamxapi.my.id/snippet/raw/nimegami" -o nimegami.js * * Usage: * node nimegami.js "latest" * node nimegami.js "list" 1 * node nimegami.js "search" "bleach" * node nimegami.js "detail" "bleach-sennen-kessen-hen-sub-indo" * node nimegami.js "stream" "bleach-sennen-kessen-hen-sub-indo" 1 "720p" */ const axios = require("axios"); const cheerio = require("cheerio"); const BASE_URL = "https://nimegami.id"; const DEFAULT_HEADERS = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "Accept-Language": "id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7", }; /** * Format relative image URL to absolute URL */ function resolveUrl(url) { if (!url) return null; if (url.startsWith("http://") || url.startsWith("https://")) return url; if (url.startsWith("/")) return `${BASE_URL}${url}`; return `${BASE_URL}/${url}`; } /** * Clean slug string */ function cleanSlug(str) { if (!str) return ""; return str .replace(/^https?:\/\/[^\/]+/, "") .replace(/^\//, "") .replace(/\/$/, ""); } /** * Parse anime card element */ function parseCard($, el) { const $el = $(el); const cardTitle = $el.find(".card-title"); const title = cardTitle.text().trim(); const rawHref = cardTitle.attr("href") || $el.find(".poster-link").attr("href") || ""; const slug = cleanSlug(rawHref); let poster = $el.find("img.poster-image, .poster-link img, img").first().attr("src") || null; if (poster && poster.includes("url=")) { try { const match = poster.match(/url=([^&]+)/); if (match) poster = decodeURIComponent(match[1]); } catch (_) {} } const format = $el.find(".format-badge").text().trim() || null; const score = $el.find(".score-badge").text().trim() || null; const lastEpisodeText = $el.find(".card-last-episode").text().replace(/Episode Terakhir:\s*/i, "").trim(); const metaText = $el.find(".card-meta").text().trim(); return { title, slug, url: `${BASE_URL}/${slug}/`, poster: resolveUrl(poster), format, score, lastEpisode: lastEpisodeText || null, meta: metaText || null }; } /** * 1. Fetch latest releases (Rilis Terbaru) */ async function latest() { try { const { data: html } = await axios.get(BASE_URL, { headers: DEFAULT_HEADERS, timeout: 10000 }); const $ = cheerio.load(html); const items = []; $(".anime-card").each((_, el) => { const card = parseCard($, el); if (card.slug && card.title) { items.push(card); } }); return { status: true, creator: "Vamz Spectre", type: "latest", totalFound: items.length, anime: items }; } catch (err) { return { status: false, creator: "Vamz Spectre", error: err.message || "Failed to fetch latest anime releases" }; } } /** * 2. Fetch anime catalog list with pagination */ async function list(page = 1, sort = "updated") { try { const targetUrl = `${BASE_URL}/anime/?sort=${sort}&page=${page}`; const { data: html } = await axios.get(targetUrl, { headers: DEFAULT_HEADERS, timeout: 10000 }); const $ = cheerio.load(html); const items = []; $(".anime-card").each((_, el) => { const card = parseCard($, el); if (card.slug && card.title) { items.push(card); } }); // Extract pagination total let totalPages = Number(page); $("a[href*='page=']").each((_, el) => { const href = $(el).attr("href") || ""; const match = href.match(/page=(\d+)/); if (match) { const p = parseInt(match[1], 10); if (p > totalPages) totalPages = p; } }); return { status: true, creator: "Vamz Spectre", type: "list", currentPage: Number(page), totalPages, totalFound: items.length, anime: items }; } catch (err) { return { status: false, creator: "Vamz Spectre", error: err.message || "Failed to fetch anime catalog" }; } } /** * 3. Search anime by query */ async function search(query) { try { const encoded = encodeURIComponent(query); // Quick suggestion API check let suggestions = []; try { const { data: apiData } = await axios.get(`${BASE_URL}/api/anime-search/?q=${encoded}`, { headers: DEFAULT_HEADERS, timeout: 5000 }); if (apiData && Array.isArray(apiData.suggestions)) { suggestions = apiData.suggestions.map(s => ({ title: s.title, slug: s.slug, url: `${BASE_URL}/${s.slug}/`, poster: resolveUrl(s.poster), format: s.format, year: s.year })); } } catch (_) {} // Full search page const { data: html } = await axios.get(`${BASE_URL}/anime/?q=${encoded}`, { headers: DEFAULT_HEADERS, timeout: 10000 }); const $ = cheerio.load(html); const items = []; $(".anime-card").each((_, el) => { const card = parseCard($, el); if (card.slug && card.title) { items.push(card); } }); return { status: true, creator: "Vamz Spectre", type: "search", query, totalFound: items.length, suggestions, anime: items }; } catch (err) { return { status: false, creator: "Vamz Spectre", error: err.message || "Failed to search anime" }; } } /** * 4. Fetch anime detail & downloads */ async function detail(slugOrUrl) { try { const slug = cleanSlug(slugOrUrl); const targetUrl = `${BASE_URL}/${slug}/`; const { data: html } = await axios.get(targetUrl, { headers: DEFAULT_HEADERS, timeout: 10000 }); const $ = cheerio.load(html); const title = $("h1").first().text().trim(); let banner = $("link[as=\"image\"][href*=\"banners\"]").attr("href") || null; let poster = $("img[src*=\"posters\"]").first().attr("src") || null; if (poster && poster.includes("url=")) { try { const match = poster.match(/url=([^&]+)/); if (match) poster = decodeURIComponent(match[1]); } catch (_) {} } const synopsis = $(".rich-content").first().text().trim() || $("meta[name=\"description\"]").attr("content") || null; // Extract table info const info = {}; $(".anime-info dl div").each((_, el) => { const key = $(el).find("dt").text().trim(); const val = $(el).find("dd").text().trim(); if (key && val) { const cleanKey = key.toLowerCase() .replace(/\s+/g, "_") .replace(/[^a-z0-9_]/g, ""); info[cleanKey] = val; } }); // Extract Genres const genres = []; $("a[href*=\"/category/\"], a[href*=\"/genre/\"], .genre-badge").each((_, el) => { const g = $(el).text().trim(); if (g && !genres.includes(g) && g !== "Genre") { genres.push(g); } }); // Extract Batch downloads const batchDownloads = []; $(".download-batch-part, .download-batch").each((_, el) => { const partTitle = $(el).find("h4, .batch-part-title").text().trim() || "Batch Download"; const qualities = []; $(el).find(".download-row").each((_, row) => { const quality = $(row).find(".quality-label strong").text().trim(); const mirrors = []; $(row).find(".download-mirrors a").each((_, a) => { const href = $(a).attr("href") || ""; mirrors.push({ name: $(a).attr("title") || "Download", url: resolveUrl(href) }); }); if (quality && mirrors.length > 0) { qualities.push({ quality, mirrors }); } }); if (qualities.length > 0) { batchDownloads.push({ title: partTitle, qualities }); } }); // Extract Per-Episode downloads const episodeDownloads = []; $("[id^=\"download_episode_\"]").each((_, el) => { const epId = $(el).attr("id") || ""; const epNum = epId.replace(/^download_episode_/, ""); const epTitle = $(el).find("h3, h4, .download-per-episode-header").text().trim() || `Episode ${epNum}`; const qualities = []; $(el).find(".download-row").each((_, row) => { const quality = $(row).find(".quality-label strong").text().trim(); const mirrors = []; $(row).find(".download-mirrors a").each((_, a) => { const href = $(a).attr("href") || ""; const name = $(a).attr("title") || "Download"; mirrors.push({ name, url: resolveUrl(href) }); }); if (quality && mirrors.length > 0) { qualities.push({ quality, mirrors }); } }); episodeDownloads.push({ episode: epNum, title: epTitle, qualities }); }); return { status: true, creator: "Vamz Spectre", result: { title, slug, url: targetUrl, poster: resolveUrl(poster), banner: resolveUrl(banner), synopsis, genres, info, batchDownloads, episodeDownloads } }; } catch (err) { return { status: false, creator: "Vamz Spectre", error: err.message || "Failed to fetch anime detail" }; } } /** * 5. Extract direct MP4 streaming video URL */ async function stream(slugOrUrl, episode = "1", preferredQuality = "720p") { try { const slug = cleanSlug(slugOrUrl); // First fetch detail to find streaming mediaId for episode const detailData = await detail(slug); if (!detailData.status) throw new Error(detailData.error); const ep = detailData.result.episodeDownloads.find(e => String(e.episode) === String(episode)) || detailData.result.episodeDownloads[0]; if (!ep) { throw new Error(`Episode ${episode} not found for ${slug}`); } // Find quality mirror let matchedQuality = ep.qualities.find(q => q.quality.toLowerCase() === preferredQuality.toLowerCase()) || ep.qualities[0]; if (!matchedQuality || !matchedQuality.mirrors || matchedQuality.mirrors.length === 0) { throw new Error(`No mirror available for episode ${episode}`); } // Extract mediaId from download URL: /bleach-sennen-kessen-hen-sub-indo/download/1/720p/293009a7-5411-4a18-96d8-444a84754f54/ const dlUrl = matchedQuality.mirrors[0].url; const mediaIdMatch = dlUrl.match(/\/download\/\d+\/[^\/]+\/([a-f0-9\-]+)/); const mediaId = mediaIdMatch ? mediaIdMatch[1] : null; if (!mediaId) { throw new Error(`Could not extract mediaId from mirror URL: ${dlUrl}`); } const streamPageUrl = `${BASE_URL}/${slug}/streaming/${episode}/${matchedQuality.quality}/${mediaId}/`; const { data: html } = await axios.get(streamPageUrl, { headers: DEFAULT_HEADERS, timeout: 10000 }); const $ = cheerio.load(html); const player = $("#player"); const streamUrl = player.attr("data-src") || null; const streamTitle = player.attr("data-title") || null; // Available quality options on player const availableQualities = []; $(".quality-option").each((_, el) => { const qUrl = $(el).attr("data-quality-url"); const mId = $(el).attr("data-media-id"); const resMatch = (qUrl || "").match(/\/streaming\/\d+\/([^\/]+)\//); const quality = resMatch ? resMatch[1] : $(el).text().replace(/[^0-9p]/gi, ""); if (qUrl) { availableQualities.push({ quality, mediaId: mId, url: resolveUrl(qUrl) }); } }); return { status: true, creator: "Vamz Spectre", result: { anime: detailData.result.title, slug, episode: Number(episode), quality: matchedQuality.quality, title: streamTitle, mediaId, streamUrl, availableQualities } }; } catch (err) { return { status: false, creator: "Vamz Spectre", error: err.message || "Failed to extract video stream" }; } } // Module Exports module.exports = { latest, list, search, detail, stream }; // CLI Execution Runner if (require.main === module) { (async () => { const action = process.argv[2] ? process.argv[2].trim() : "latest"; const param1 = process.argv[3] ? process.argv[3].trim() : ""; const param2 = process.argv[4] ? process.argv[4].trim() : ""; const param3 = process.argv[5] ? process.argv[5].trim() : ""; let res; if (action === "latest" || action === "home") { res = await latest(); } else if (action === "list" || action === "catalog") { res = await list(param1 || 1, param2 || "updated"); } else if (action === "search") { res = await search(param1 || "naruto"); } else if (action === "detail") { res = await detail(param1 || "bleach-sennen-kessen-hen-sub-indo"); } else if (action === "stream") { res = await stream(param1 || "bleach-sennen-kessen-hen-sub-indo", param2 || "1", param3 || "720p"); } else if (action.includes("-sub-indo") || action.includes("http")) { res = await detail(action); } else { res = await search(action); } console.log(JSON.stringify(res, null, 2)); })(); }