UNPKG

rsshub

Version:
78 lines (76 loc) 2.42 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 "./helpers-DxBp0Pty.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { n as rootUrl, t as getSearchParams } from "./utils-BwpBAMuc.mjs"; import path from "node:path"; //#region lib/routes/cls/telegraph.ts init_esm_shims(); const categories = { watch: "看盘", announcement: "公司", explain: "解读", red: "加红", jpush: "推送", remind: "提醒", fund: "基金", hk: "港股" }; const route = { path: "/telegraph/:category?", categories: ["finance"], example: "/cls/telegraph", parameters: { category: "分类,见下表,默认为全部" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["cls.cn/telegraph", "cls.cn/"], target: "/telegraph" }], name: "电报", maintainers: ["nczitzk"], handler, url: "cls.cn/telegraph", description: `| 看盘 | 公司 | 解读 | 加红 | 推送 | 提醒 | 基金 | 港股 | | ----- | ------------ | ------- | ---- | ----- | ------ | ---- | ---- | | watch | announcement | explain | red | jpush | remind | fund | hk |` }; async function handler(ctx) { const category = ctx.req.param("category") ?? ""; const limit = ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 50; let apiUrl = `${rootUrl}/nodeapi/updateTelegraphList`; if (category) apiUrl = `${rootUrl}/v1/roll/get_roll_list`; const currentUrl = `${rootUrl}/telegraph`; const items = (await got_default({ method: "get", url: apiUrl, searchParams: getSearchParams({ category, hasFirstVipArticle: 1 }) })).data.data.roll_data.slice(0, limit).map((item) => ({ title: item.title || item.content, link: item.shareurl, description: art(path.join(__dirname, "templates/telegraph-f8ba0f7b.art"), { item }), pubDate: parseDate(item.ctime * 1e3), category: item.subjects?.map((s) => s.subject_name) })); return { title: `财联社 - 电报${category === "" ? "" : ` - ${categories[category]}`}`, link: currentUrl, item: items }; } //#endregion export { route };