UNPKG

rsshub

Version:
134 lines (132 loc) 3.83 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 { t as timezone } from "./timezone-D8cuwzTY.mjs"; import path from "node:path"; import { load } from "cheerio"; //#region lib/routes/005/index.ts init_esm_shims(); const handler = async (ctx) => { const { category = "zx" } = ctx.req.param(); const limit = ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit"), 10) : 20; const rootUrl = "https://005.tv"; const currentUrl = new URL(category ? `${category}/` : "", rootUrl).href; const { data: response } = await got_default(currentUrl); const $ = load(response); const language = $("html").prop("lang"); let items = $("div.article-list ul li").slice(0, limit).toArray().map((item) => { item = $(item); const title$1 = item.find("h3").text(); const image$1 = item.find("img").prop("src"); const description = art(path.join(__dirname, "templates/description-4eefda61.art"), { intro: item.find("div.p-row").text(), images: image$1 ? [{ src: image$1, alt: title$1 }] : void 0 }); return { title: title$1, description, pubDate: parseDate(item.find("span.time").text()), link: new URL(item.find("h3 a").prop("href"), rootUrl).href, content: { html: description, text: item.find("div.p-row").text() }, image: image$1, banner: image$1, language }; }); items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => { const { data: detailResponse } = await got_default(item.link); const $$ = load(detailResponse); const title$1 = $$("h1.articleTitle-name").text(); const description = $$("div.articleContent").html(); item.title = title$1; item.description = description; item.pubDate = timezone(parseDate($$(".time").text()), 8); item.category = $$("meta[name=\"keywords\"]").prop("content").split(/,/); item.content = { html: description, text: $$("div.articleContent").text() }; item.language = language; return item; }))); const title = $("title").text(); const image = new URL("templets/muban/style/images/logo.png", rootUrl).href; return { title, description: title.split(/_/)[0], link: currentUrl, item: items, allowEmpty: true, image, author: title.split(/,/).pop(), language }; }; const route = { path: "/:category?", name: "资讯", url: "005.tv", maintainers: ["nczitzk"], handler, example: "/005/zx", parameters: { category: "分类,可在对应分类页 URL 中找到,默认为二次元资讯" }, description: ` | 二次元资讯 | 慢慢说 | 道听途说 | 展会资讯 | | ---------- | ------ | -------- | -------- | | zx | zwh | dtts | zh | `, categories: ["anime"], features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportRadar: true, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [ { source: ["005.tv/:category"], target: (params) => { const category = params.category; return `/005${category ? `/${category}` : ""}`; } }, { title: "二次元资讯", source: ["005.tv/zx/"], target: "/005/zx" }, { title: "慢慢说", source: ["005.tv/zwh/"], target: "/005/zwh" }, { title: "道听途说", source: ["005.tv/dtts/"], target: "/005/dtts" }, { title: "展会资讯", source: ["005.tv/zh/"], target: "/005/zh" } ] }; //#endregion export { handler, route };