rsshub
Version:
Make RSS Great Again!
77 lines (75 loc) • 2.7 kB
JavaScript
import "./dist-Bog6z_OM.mjs";
import "./config-MQ-7ebJ_.mjs";
import "./logger-C4avouvV.mjs";
import "./ofetch-DKl_Ma9g.mjs";
import { t as parseDate } from "./parse-date-r5WDWHno.mjs";
import "./helpers-Bo4JQYdN.mjs";
import { t as got_default } from "./got-CO-ndVl2.mjs";
import { n as rootUrl, t as getSearchParams } from "./utils-BuzNXSy7.mjs";
import { Fragment, jsx, jsxs } from "hono/jsx/jsx-runtime";
import { renderToString } from "hono/jsx/dom/server";
//#region lib/routes/cls/telegraph.tsx
const categories = {
watch: "看盘",
announcement: "公司",
explain: "解读",
red: "加红",
jpush: "推送",
remind: "提醒",
fund: "基金",
hk: "港股"
};
const renderTelegraphDescription = (item) => renderToString(/* @__PURE__ */ jsxs(Fragment, { children: [item.content ? /* @__PURE__ */ jsx(Fragment, { children: item.content }) : null, item.images?.length ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("br", {}), item.images.map((image) => /* @__PURE__ */ jsx("img", { src: image }, image))] }) : null] }));
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: renderTelegraphDescription(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 };