UNPKG

rsshub

Version:
76 lines (73 loc) 2.39 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"; //#region lib/routes/xkb/index.ts init_esm_shims(); const route = { path: "/:channel", categories: ["traditional-media"], example: "/xkb/350", parameters: { channel: "栏目 ID,点击对应栏目后在地址栏找到" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "新闻", maintainers: ["TimWu007"], handler, description: `常用栏目 ID: | 栏目名 | ID | | ------ | --- | | 首页 | 350 | | 重点 | 359 | | 广州 | 353 | | 湾区 | 360 | | 天下 | 355 |` }; async function handler(ctx) { const channel = ctx.req.param("channel") ?? 350; const { data: response } = await got_default({ method: "get", url: `https://www.xkb.com.cn/xkbapp/fundapi/article/api/articles?chnlId=${channel}&visibility=1&page=0&size=20&keyword=`, headers: { siteId: 35 } }); const list = response.data.filter((i) => i.contentUrl).map((item) => ({ title: item.listTitle, description: art(path.join(__dirname, "templates/description-60b509f9.art"), { thumb: item.shareImg }), pubDate: timezone(parseDate(item.operTime), 8), link: "https://www.xkb.com.cn/detail?id=" + item.id, contentUrl: item.contentUrl, author: item.metaInfo.author, chnlName: item.metaInfo.chnlName })); let chnlName = ""; const items = await Promise.all(list.map((item) => cache_default.tryGet(item.contentUrl, async () => { const detailResponse = await got_default({ method: "get", url: item.contentUrl }); item.description += detailResponse.data.htmlContent ?? ""; chnlName = chnlName === "" ? item.chnlName : chnlName; return item; }))); return { title: `新快报新快网 - ${chnlName}`, link: `https://www.xkb.com.cn/home?id=${channel}`, item: items }; } //#endregion export { route };