UNPKG

rsshub

Version:
57 lines (55 loc) 1.97 kB
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"; import { load } from "cheerio"; //#region lib/routes/wmc-bj/publish.ts init_esm_shims(); const route = { path: "/publish/:category{.+}?", name: "Unknown", maintainers: [], handler }; async function handler(ctx) { const { category = "CRA-Reanalysis/2m-Temperature/6-hour/index.html" } = ctx.req.param(); const currentUrl = new URL(`publish/${category}`, "http://www.wmc-bj.net").href; const { data: response } = await got_default(currentUrl); const $ = load(response); const title = $("title").text(); const author = "World Meteorological Centre BeiJing"; const img = $("#imgpath"); const datetime = img.prop("data-time"); const categories = $("ol.breadcrumb li").slice(2).toArray().map((b) => $(b).text()); const items = [{ title: `${datetime} ${title}`, link: currentUrl, description: art(path.join(__dirname, "templates/description-8504ee0e.art"), { image: { src: img.prop("src").replace(/\/medium\//, "/") } }), category: categories, guid: `${currentUrl}#${datetime}`, pubDate: timezone(parseDate(/^[A-Za-z]{3}/.test(datetime) ? datetime.replace(/^\w+/, "") : datetime, ["DD MMM HH:mm", "MM/DD HH:mm"]), 0) }]; const image = "http://image.nmc.cn/static/wmc/img/logo-cma.png"; const icon = $("link[rel=\"shortcut icon\"]").prop("href"); return { item: items, title, link: currentUrl, language: "en", image, icon, logo: icon, subtitle: categories.join(" > "), author, allowEmpty: true }; } //#endregion export { route };