UNPKG

rsshub

Version:
51 lines (49 loc) 1.93 kB
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.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/qq/ac/utils.ts init_esm_shims(); const rootUrl = "https://ac.qq.com"; const mobileRootUrl = "https://m.ac.qq.com"; const ProcessItems = async (ctx, currentUrl, time, title) => { const $ = load((await got_default({ method: "get", url: currentUrl })).data); let items = $(`${time ? `.${time}-month-data ` : ""}.text-overflow`).slice(0, ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 30).toArray().map((item) => { item = $(item); return { title: item.text(), guid: `${rootUrl}${item.attr("href")}`, link: `${mobileRootUrl}${item.attr("href").replace(/Comic\/ComicInfo/, "comic/index")}` }; }); items = await Promise.all(items.map((item) => cache_default.tryGet(item.guid, async () => { const content = load((await got_default({ method: "get", url: item.link })).data); item.link = item.guid; item.author = content(".author-wr").toArray().map((a) => $(a).text().trim()).join(", "); item.description = art(path.join(__dirname, "templates/description-a80571be.art"), { image: content(".head-cover")?.attr("src") ?? "", description: content(".head-info-desc")?.text() ?? "", chapters: content(".reverse .bottom-chapter-item .chapter-link").toArray().map((chapter) => ({ link: content(chapter).attr("href"), title: content(chapter).find(".comic-title")?.text() ?? "", image: content(chapter).find(".cover-image")?.attr("src") ?? "" })) }); return item; }))); return { title: `${title} - 腾讯动漫`, link: currentUrl, item: items }; }; //#endregion export { mobileRootUrl as n, rootUrl as r, ProcessItems as t };