rsshub
Version:
Make RSS Great Again!
84 lines (82 loc) • 2.78 kB
JavaScript
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 { t as timezone } from "./timezone-D8cuwzTY.mjs";
import path from "node:path";
//#region lib/routes/gov/caac/cjwt.ts
init_esm_shims();
const route = {
path: "/caac/cjwt/:category?",
categories: ["government"],
example: "/gov/caac/cjwt",
parameters: { category: "分类,见下表,默认为全部" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{
source: ["caac.gov.cn/HDJL/"],
target: "/caac/cjwt"
}],
name: "公众留言",
maintainers: ["nczitzk"],
handler,
url: "caac.gov.cn/HDJL/",
description: `| 机票 | 托运 | 无人机 | 体检 | 行政审批 | 投诉 |
| ---- | ---- | ------ | ---- | -------- | ---- |`
};
async function handler(ctx) {
const { category = "" } = ctx.req.param();
const limit = ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit"), 10) : 30;
const rootUrl = "https://www.caac.gov.cn";
const apiUrl = new URL(`caacgov/jsonp/messageBoard/visit/get${category ? "CJWT" : ""}List`, rootUrl).href;
const currentUrl = new URL("HDJL/", rootUrl).href;
const { data: response } = await got_default(apiUrl, { searchParams: {
callbackparam: "jsonp_messageBoard_getList",
infoMess: category,
pageIndex: 1
} });
const items = JSON.parse(response.match(/jsonp_messageBoard_getList\((.*?)\)$/)[1]).returnData.root.slice(0, limit).map((item) => ({
title: item.infoMess.replaceAll(/<\/?em>/g, ""),
link: new URL(`index_180.html?info=${item.id}&type=id`, rootUrl).href,
description: art(path.join(__dirname, "templates/description-69474502.art"), { item }),
author: `${item.gname}/${item.feedbackName}`,
category: [item.messageType],
guid: `caac-cjwt#${item.id}`,
pubDate: timezone(parseDate(item.createDate), 8),
updated: timezone(parseDate(item.feedbackDate), 8)
}));
const author = "中国民用航空局";
const image = new URL("images/Logo2.png", rootUrl).href;
const icon = new URL("images/weixinLogo.jpg", rootUrl).href;
const subtitle = "公众留言";
return {
item: items,
title: [
author,
subtitle,
category
].filter(Boolean).join(" - "),
link: currentUrl,
description: "向公众提供服务和开展互动交流",
language: "zh",
image,
icon,
logo: icon,
subtitle,
author,
allowEmpty: true
};
}
//#endregion
export { route };