rsshub
Version:
Make RSS Great Again!
62 lines (61 loc) • 2.44 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { t as timezone } from "./timezone-DE--ze1V.mjs";
import { load } from "cheerio";
//#region lib/routes/tsinghua/lib/tzgg.ts
const route = {
path: "/lib/tzgg/:category?",
url: "lib.tsinghua.edu.cn",
categories: ["university"],
example: "/tsinghua/lib/tzgg/qtkx",
parameters: { category: "分类,可在对应分类页 URL 中找到,留空则获取全局通知公告" },
description: `| 全部 | 开馆通知 | 施工维修 | 服务通知 | 违规通报 | 清图快讯 | 馆际通知 |
| ---- | -------- | -------- | -------- | -------- | -------- | -------- |
| 留空 | kgtz | sgwx | fwtz | wgtb | qtkx | gjtz |`,
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["lib.tsinghua.edu.cn/tzgg/:category", "lib.tsinghua.edu.cn/tzgg.htm"] }],
name: "图书馆通知公告",
maintainers: ["linsenwang", "Aquarius-Situla"],
handler
};
async function handler(ctx) {
const { category } = ctx.req.param();
const host = category ? `https://lib.tsinghua.edu.cn/tzgg/${category}.htm` : "https://lib.tsinghua.edu.cn/tzgg.htm";
const $ = load(await rofetch(host));
const feedTitle = category ? $(".tags .on").text() : "通知公告";
const image = new URL($("div.logo a img").attr("src") || "images/logo.png", "https://lib.tsinghua.edu.cn").href;
const list = $("ul.notice-list li").toArray().filter((item) => $(item).find("a").attr("href")).map((item) => {
const $item = $(item);
const title = $item.find("a").text();
const time = $item.find(".notice-date").text();
const a = $item.find("a").attr("href");
const itemCategory = category ? feedTitle : $item.find(".notice-label").text();
return {
title,
link: new URL(a, host).href,
pubDate: timezone(parseDate(time, "YYYY-MM-DD"), 8),
category: itemCategory
};
});
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
item.description = load(await rofetch(item.link))(".v_news_content").html() || void 0;
return item;
})));
return {
allowEmpty: true,
title: "图书馆通知公告 - " + feedTitle,
link: host,
image,
item: items
};
}
//#endregion
export { route };