UNPKG

rsshub

Version:
84 lines (82 loc) 3.09 kB
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import path from "node:path"; import { load } from "cheerio"; //#region lib/routes/rawkuma/manga.ts init_esm_shims(); const route = { path: "/manga/:id", categories: ["anime"], example: "/rawkuma/manga/tensei-shitara-dai-nana-ouji-dattanode-kimamani-majutsu-o-kiwamemasu", parameters: { id: "Manga ID, can be found in URL" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false, nsfw: true }, radar: [{ source: ["rawkuma.com/manga/:id", "rawkuma.com/"] }], name: "Manga", maintainers: ["nczitzk"], handler }; async function handler(ctx) { const id = ctx.req.param("id"); const limit = ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit"), 10) : 50; const currentUrl = new URL(`/manga/${id}`, "https://rawkuma.com").href; const { data: response } = await got_default(currentUrl); const $ = load(response); const author = $("div.fmed span").eq(1).text().trim(); const category = $("div.wd-full span.mgen a[rel=\"tag\"]").toArray().map((c) => $(c).text()); let items = $("div.eph-num").slice(0, limit).toArray().map((item) => { item = $(item); return { title: item.find("span.chapternum").text(), link: item.find("a").prop("href"), author, category, pubDate: parseDate(item.find("span.chapterdate").text(), "MMMM DD"), enclosure_url: item.next().find("a.dload").prop("href"), enclosure_type: "application/zip" }; }); items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => { const { data: detailResponse } = await got_default(item.link); const content = load(detailResponse); const imageMatches = detailResponse.match(/"images":(\[.*?])}],"lazyload"/); const images = imageMatches ? JSON.parse(imageMatches[1]) : []; item.title = content("div.chpnw").text().trim(); item.description = art(path.join(__dirname, "templates/description-b5285b5a.art"), { images }); item.author = author; item.category = category; item.pubDate = parseDate(content("time.entry-date").prop("datetime").replace(/WIB/, "T")); item.enclosure_url = content("span.dlx a").prop("href"); item.enclosure_type = "application/zip"; return item; }))); const icon = $("link[rel=\"apple-touch-icon\"]").prop("href").replace(/-\d+x\d+/, ""); return { item: items, title: $("title").text(), link: currentUrl, description: $("div[itemprop=\"description\"]").text(), image: $("meta[property=\"og:image\"]").prop("content"), icon, logo: icon, subtitle: $("div.wd-full span").text(), author }; } //#endregion export { route };