UNPKG

rsshub

Version:
88 lines (87 loc) 3.54 kB
import { t as parseDate } from "./parse-date-Cr0wQjV_.mjs"; import { t as got_default } from "./got-BTowW50G.mjs"; import { t as timezone } from "./timezone-BBvDwS_3.mjs"; import dayjs from "dayjs"; import { jsx, jsxs } from "hono/jsx/jsx-runtime"; import { load } from "cheerio"; import { renderToString } from "hono/jsx/dom/server"; //#region lib/routes/3gmuseum/namespace.ts const namespace = { name: "Chongqing China Three Gorges Museum", url: "www.3gmuseum.cn", zh: { name: "重庆中国三峡博物馆" } }; //#endregion //#region lib/routes/3gmuseum/exhibition.tsx const route = { path: "/tempexhibition", categories: ["travel"], example: "/3gmuseum/tempexhibition", name: "Temporary Exhibition", maintainers: ["magazian"], radar: [{ source: ["www.3gmuseum.cn/web/column/col5009287.html"], target: "/tempexhibition" }], handler: async () => { const apiUrl = `https://www.3gmuseum.cn/web/column/col5009287.html`; const museumName = namespace.zh?.name || namespace.name; const response = await got_default({ method: "get", url: apiUrl }); const idx = response.data.indexOf("var newsPageTotal = "); const endIdx = response.data.indexOf("\n", idx); const str = response.data.slice(idx + 20, endIdx).trim(); const items = (JSON.parse(str)?.list).map((item) => { const article = item.article; const itemLink = article.pcUrl; const $listContent = load(article.content); const location = $listContent("p:contains(\"地点:\")").text().replace(/.*?(?:展览|展出)?地点:/, "").trim(); const fullDuration = $listContent("p:contains(\"时间:\")").text().replace(/.*?(?:展览|展出)?时间:?/, "").trim(); let startDate; let endDate; if (fullDuration) { const dateMatch = fullDuration.match(/(\d{4}[年.]\d{1,2}[月.]\d{1,2}日?)\s*[—\-~至]+\s*(\d{4}[年.])?(\d{1,2}[月.]\d{1,2}日?)/); if (dateMatch) { const startStr = dateMatch[1].replaceAll(/[年月.]/g, "-").replace("日", ""); const endStr = (dateMatch[2] ? dateMatch[2].replaceAll(/[年.]/g, "-") : startStr.slice(0, 5)) + dateMatch[3].replaceAll(/[月.]/g, "-").replace("日", ""); startDate = dayjs(startStr).format("YYYY-MM-DD"); endDate = dayjs(endStr).format("YYYY-MM-DD"); } } else { const formMap = article.formMap; startDate = dayjs(formMap.extend_field_starttime).format("YYYY-MM-DD"); endDate = dayjs(formMap.extend_field_endtime).format("YYYY-MM-DD"); } const pubDate = timezone(parseDate(item.pubTime), 8); return { title: item.listTitle, link: itemLink, pubDate, description: renderToString(/* @__PURE__ */ jsxs("div", { children: [ /* @__PURE__ */ jsx("img", { src: `https:${item.listImage}` }), /* @__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: apiUrl, language: "zh-CN", item: items }; } }; //#endregion export { route };