const axios = require('axios'); const cheerio = require('cheerio'); const BASE = 'https://komiku.org'; const HEADERS = { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) 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;q=0.8' }; module.exports = { path: '/komik/komiku/detail?apikey=&url=', name: 'Komiku Detail', id: 'detail', category: 'Komik', params: [ { name: 'url', required: true, example: 'https://komiku.org/manga/from-goblin-to-goblin-god/', description: 'URL lengkap halaman komik di Komiku', }, ], desc: 'Ambil detail informasi dan daftar chapter komik.', async run(req, res) { const url = String(req.query.url || req.body.url || '').trim(); if (!url) return res.status(400).json({ status: false, message: 'Parameter url diperlukan' }); if (!url.startsWith(BASE)) { return res.status(400).json({ status: false, message: 'URL tidak valid' }); } try { const { data: html } = await axios.get(url, { headers: HEADERS, timeout: 30000 }); const $ = cheerio.load(html); const thumbnail = $('.ims img').attr('src'); const judul = $('h1 span').text().trim(); const judulAlternatif = $('.j2').text().trim(); const tipe = $('.inftable td').eq(5).text().trim(); const tema = $('.inftable td').eq(7).text().trim(); const genre = []; $('.genre li a span').each((i, el) => { genre.push($(el).text().trim()); }); const author = $('.inftable td').eq(11).text().trim(); const status = $('.inftable td').eq(13).text().trim(); const rating = $('.inftable td').eq(15).text().trim(); const caraBaca = $('.inftable td').eq(19).text().trim(); const sinopsis = $('.desc').text().trim(); const pembacaText = $('.inftable td').eq(17).text().trim(); let totalViews = ''; let weeklyViews = ''; if (pembacaText) { const matchTotal = pembacaText.match(/Total:\s*([\d,.]+(rb|jt)?)/); const matchWeekly = pembacaText.match(/Minggu ini:\s*([\d,.]+)/); totalViews = matchTotal ? matchTotal[1] : ''; weeklyViews = matchWeekly ? matchWeekly[1] : ''; } let datePublished = ''; let dateModified = ''; const jsonLdMatch = html.match(/