rsshub
Version:
Make RSS Great Again!
82 lines (81 loc) • 3.29 kB
JavaScript
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs";
import { t as parseDate } from "./parse-date-3kcy2Eau.mjs";
import { t as cache_default } from "./cache-C1Y-9qDV.mjs";
import { t as timezone } from "./timezone-UiMFOuvL.mjs";
import { jsx, jsxs } from "hono/jsx/jsx-runtime";
import { load } from "cheerio";
import { renderToString } from "hono/jsx/dom/server";
//#region lib/routes/namoc/namespace.ts
const namespace = {
name: "National Art Museum of China",
url: "www.namoc.cn",
zh: { name: "中国美术馆" }
};
//#endregion
//#region lib/routes/namoc/zhanlan.tsx
const baseUrl = "https://www.namoc.cn";
const listUrl = `${baseUrl}/namoc/zhanlan/zl_list.shtml`;
const route = {
path: "/zhanlan",
categories: ["travel"],
example: "/namoc/zhanlan",
name: "Exhibitions",
maintainers: ["magazian"],
radar: [{
source: ["www.namoc.cn/namoc/zhanlan/zl_list.shtml"],
target: "/zhanlan"
}],
handler: async () => {
const museumName = namespace.zh?.name || namespace.name;
const response = await rofetch(listUrl);
const $ = load(response);
const items = await Promise.all($("ul.zllist#zlhglb > li.clearfix").toArray().map((el) => {
const $li = $(el);
const $titleAnchor = $li.find("div.text h3 > a");
const title = $titleAnchor.attr("title") || "";
const rawLink = $titleAnchor.attr("href") || "";
const link = new URL(rawLink, baseUrl).href;
const fullDuration = $li.find("div.text div p").filter((_, p) => $(p).text().startsWith("展览时间:")).text().replace("展览时间:", "");
const location = $li.find("div.text div p").filter((_, p) => $(p).text().startsWith("展览场地:")).text().replace("展览场地:", "");
const dateParts = fullDuration.split("至");
const startDate = dateParts[0] || void 0;
const endDate = dateParts[1] || void 0;
const scriptText = $li.find("p.image script").text();
const images = JSON.parse(scriptText.match(/var\s+jsonImageStr\s*=\s*'(\[.*?\])'/s)[1]);
const imgUrl = new URL(images[0].savepath, baseUrl).href;
return cache_default.tryGet(link, async () => {
const detailHtml = await rofetch(link);
const pubDateStr = load(detailHtml)("meta[name=\"PubDate\"]").attr("content") || "";
const pubDate = timezone(parseDate(pubDateStr), 8);
const 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] }) })
] }));
return {
title,
link,
pubDate,
description,
_extra: {
museumName,
location,
startDate,
endDate
}
};
});
}));
return {
title: `${museumName} - 展览`,
link: listUrl,
language: "zh-CN",
item: items
};
}
};
//#endregion
export { route };