rsshub
Version:
Make RSS Great Again!
68 lines (66 loc) • 2.03 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import "./ofetch-BIyrKU3Y.mjs";
import "./parse-date-BrP7mxXf.mjs";
import "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import "./render-BQo6B4tL.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { t as utils_default } from "./utils-CiJlffWL.mjs";
import { load } from "cheerio";
//#region lib/routes/thepaper/channel.ts
const route = {
path: "/channel/:id",
categories: ["new-media"],
example: "/thepaper/channel/25950",
parameters: { id: "频道 id,可在频道页 URL 中找到" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
name: "频道",
maintainers: [
"xyqfer",
"nczitzk",
"bigfei"
],
handler,
description: `| 频道 ID | 频道名 |
| ------- | ------ |
| 26916 | 视频 |
| 108856 | 战疫 |
| 25950 | 时事 |
| 25951 | 财经 |
| 36079 | 澎湃号 |
| 119908 | 科技 |
| 25952 | 思想 |
| 119489 | 智库 |
| 25953 | 生活 |
| 26161 | 问吧 |
| 122908 | 国际 |
| -21 | 体育 |
| -24 | 评论 |`
};
async function handler(ctx) {
const id = ctx.req.param("id");
const channel_url = `https://m.thepaper.cn/channel/${id}`;
const channel_url_resp = await got_default(channel_url);
const channel_url_data = JSON.parse(load(channel_url_resp.data)("#__NEXT_DATA__").html());
const list = (await got_default.post("https://api.thepaper.cn/contentapi/nodeCont/getByChannelId", { json: { channelId: id } })).data.data.list;
const items = await Promise.all(list.map((item) => utils_default.ProcessItem(item, ctx)));
return {
title: `澎湃新闻频道 - ${utils_default.ChannelIdToName(id, channel_url_data)}`,
link: channel_url,
item: items,
itunes_author: "澎湃新闻",
image: utils_default.ExtractLogo(channel_url_resp)
};
}
//#endregion
export { route };