UNPKG

rsshub

Version:
84 lines (82 loc) 2.33 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import { load } from "cheerio"; //#region lib/routes/zxcs/novel.ts const types = { jinqigengxin: "近期更新", dushi: "都市", xianxia: "仙侠", xuanhuan: "玄幻", qihuan: "奇幻", lishi: "历史", youxi: "游戏", wuxia: "武侠", kehuan: "科幻", tiyu: "体育", lingyi: "灵异", junshi: "军事", erciyuan: "轻小说" }; const route = { path: "/novel/:type", name: "小说列表", url: "zxcs.info", maintainers: ["liaochuan"], example: "/zxcs/novel/jinqigengxin", parameters: { type: "小说类型, 可在对应类型页 URL 中找到" }, description: `支持小说类型:${Object.entries(types).map(([key, value]) => `${key}-${value}`).join(",")}`, categories: ["reading"], features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["zxcs.info/:type"], target: "/novel/:type" }], handler }; async function handler(ctx) { const { type } = ctx.req.param(); const baseUrl = `https://www.zxcs.info`; const link = `${baseUrl}/${type}`; const $ = load(await ofetch_default(link)); const list = $("div.book-info").toArray().map((item) => { const $item = $(item); const a = $item.find("a").first(); return { title: a.text(), link: String(a.attr("href")), pubDate: parseDate($item.find(".update").text()), category: [], description: "", image: "", author: "" }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(String(item.link), async () => { const $$1 = load(await ofetch_default(String(item.link))); const links = String(item.link).split("/"); item.category = [types[String(links.at(-2))]]; item.description = String($$1(".intro").first().html()); item.image = baseUrl + String($$1(".book-cover img").attr("src")); item.author = $$1(".author").text(); return item; }))); return { title: `知轩藏书 - ${types[type]}`, link, item: items }; } //#endregion export { route };