UNPKG

rsshub

Version:
76 lines (75 loc) 2.95 kB
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs"; import { t as parseDate } from "./parse-date-3kcy2Eau.mjs"; import { t as namespace } from "./namespace-D-kUeQsS.mjs"; import { jsx, jsxs } from "hono/jsx/jsx-runtime"; import { load } from "cheerio"; import { renderToString } from "hono/jsx/dom/server"; //#region lib/routes/canalmuseum/lszl.tsx const formatExhibitionDate = (dateStr) => { const m = dateStr.trim().match(/^(\d{4})年(\d{1,2})月(\d{1,2})日$/); return m ? `${m[1]}-${m[2].padStart(2, "0")}-${m[3].padStart(2, "0")}` : void 0; }; const parseExhibitionDuration = (fullDuration) => { const [startRaw, endRaw] = fullDuration.split("—", 2); return { startDate: formatExhibitionDate(startRaw), endDate: formatExhibitionDate(endRaw) }; }; const route = { path: "/lszl", categories: ["travel"], example: "/canalmuseum/lszl", radar: [{ source: ["www.canalmuseum.org.cn/lszl.html"], target: "/lszl" }], name: "临时展览", maintainers: ["magazian"], handler: async () => { const museumName = namespace.zh?.name || namespace.name; const baseUrl = "https://www.canalmuseum.org.cn"; const listUrl = `${baseUrl}/lszl.html`; const response = await rofetch(listUrl); const $ = load(response); const items = $(".exhibition2 .list .item").toArray().map((el) => { const $el = $(el); const imgUrl = $el.find(".image img").attr("src"); const $textA = $el.find(".text > a"); const title = $textA.find(".title1 .t1").text(); const href = $textA.attr("href") ?? ""; const link = new URL(href, baseUrl).href; const liItems = $textA.find(".ul .li").toArray().map((li) => $(li).text()); const fullDuration = liItems.find((t) => t.startsWith("时间:"))?.replace("时间:", "") ?? ""; const location = liItems.find((t) => t.startsWith("地点:"))?.replace("地点:", "") ?? ""; const { startDate, endDate } = parseExhibitionDuration(fullDuration); return { title, link, pubDate: startDate ? parseDate(startDate) : void 0, description: renderToString(/* @__PURE__ */ jsxs("div", { children: [ /* @__PURE__ */ jsx("img", { src: imgUrl }), /* @__PURE__ */ jsx("br", {}), /* @__PURE__ */ jsxs("p", { children: [/* @__PURE__ */ jsx("b", { children: "地点:" }), location || "参考详情"] }), /* @__PURE__ */ jsxs("p", { children: [/* @__PURE__ */ jsx("b", { children: "开展:" }), startDate || "未定/常设"] }), /* @__PURE__ */ jsxs("p", { children: [/* @__PURE__ */ jsx("b", { children: "闭展:" }), endDate || "未定/常设"] }), fullDuration && /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsxs("small", { children: ["原始展期:", fullDuration] }) }) ] })), _extra: { museumName, location, startDate, endDate } }; }); return { title: `${museumName} - 临时展览`, link: listUrl, language: "zh-CN", item: items }; } }; //#endregion export { route };