UNPKG

rsshub

Version:
37 lines (36 loc) 1.23 kB
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/ynu/utils.ts const processPages = ({ list, host, department }) => Promise.all(list.map(({ path, title, author }) => { const link = path.includes("http://") ? path : host + path; return cache_default.tryGet(link, async () => { const $ = load(await rofetch(link)); let dateString = ""; switch (department) { case "grs": dateString = $("#times").text().slice(5); break; case "home": dateString = $(".conttime span").text().slice(5); break; case "jwc": dateString = $(".taitshj").text().slice(5, 15); } let description = $(".v_news_content").html()?.trim(); if (department === "jwc" && $("#vsb_content").siblings().has("ul li").length > 0) { const attachment = $("#vsb_content").siblings("ul").html().trim(); description += "\n" + attachment; } return { pubDate: timezone(parseDate(dateString), 8), author, link, title, description }; }); })); //#endregion export { processPages as t };