feat(route/thepaper): Add route for government accounts (#21151)

* feat(route/thepaper): Add route for government accounts

* fix(route/thepaper): object-shorthand

* fix(route/thepaper): object-shorthand
This commit is contained in:
occam-7 2026-02-15 00:23:30 +08:00 committed by GitHub
parent d593b2e531
commit 1db6d77c17
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,53 @@
import type { Route } from "@/types";
import ofetch from "@/utils/ofetch";
import utils from "./utils";
export const route: Route = {
path: "/gov/:pphId",
categories: ["new-media"],
example: "/thepaper/gov/63850",
parameters: { pphId: "政务号 id可在政务号页 URL 中找到" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: "政务号",
maintainers: ["occam-7"],
handler,
};
async function handler(ctx) {
const { pphId } = ctx.req.param();
const pageSize = Number.parseInt(ctx.req.query("limit") ?? "10", 10);
const response = await ofetch(
"https://api.thepaper.cn/contentapi/cont/pph/gov",
{
method: "POST",
body: {
pageNum: 1,
pageSize,
pphId,
},
}
);
const list = response.data?.list ?? [];
const authorName = list[0]?.authorInfo?.sname ?? `政务号 ${pphId}`;
const items = await Promise.all(
list.map((item) => utils.ProcessItem(item, ctx))
);
return {
title: `澎湃新闻政务号 - ${authorName}`,
link: `https://www.thepaper.cn/gov_${pphId}`,
item: items,
itunes_author: authorName,
image: list[0]?.authorInfo?.pic || list[0]?.pic,
};
}