UNPKG

rsshub

Version:
60 lines (58 loc) 1.76 kB
import "./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 { r as getSubPath } from "./common-utils-vrWQFAEk.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as timezone } from "./timezone-D8cuwzTY.mjs"; //#region lib/routes/cneb/yjxx.ts const route = { path: "/yjxx/*", radar: [{ source: ["cneb.gov.cn/yjxx", "cneb.gov.cn/"], target: "/yjxx" }], name: "Unknown", maintainers: [], handler, url: "cneb.gov.cn/yjxx" }; async function handler(ctx) { const limit = ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 200; const options = decodeURI(getSubPath(ctx)).replace(/\/yjxx/, "").split("/"); options.shift(); const level = options.find((o) => /.*色$/.test(o)) ?? ""; const locations = options.filter((o) => !/.*色$/.test(o)).slice(0, 2); const rootUrl = "http://www.cneb.gov.cn"; const apiRootUrl = "https://gdapi.cnr.cn"; const currentUrl = `${rootUrl}/yjxx`; const apiUrl = `${apiRootUrl}/yjwnews`; const title = `${locations.join("")}${level}`; const items = (await got_default({ method: "post", url: apiUrl, json: { size: limit, level: level ? `${level}预警` : "", province: locations.shift(), city: locations.shift() } })).data.datas.map((item) => ({ title: item.doctitle, link: item.docpuburl, author: item.chnlname, description: item.doccontent, pubDate: timezone(parseDate(item.docpubtime), 8) })); return { title: `国家应急广播 - ${title}预警信息`, link: currentUrl, item: items, allowEmpty: true }; } //#endregion export { route };