UNPKG

rsshub

Version:
65 lines (63 loc) 1.98 kB
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import path from "node:path"; import { load } from "cheerio"; //#region lib/routes/ecnu/contest.ts init_esm_shims(); const route = { path: "/acm/contest/:category?", categories: ["university"], example: "/ecnu/acm/contest/public", parameters: { category: "category is optional, default is all, use `public` for public only contests" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["acm.ecnu.edu.cn/contest/", "acm.ecnu.edu.cn/"], target: "/acm/contest/" }], name: "ACM Online-Judge contests list", maintainers: ["a180285"], handler, url: "acm.ecnu.edu.cn/contest/" }; async function handler(ctx) { const publicOnly = (ctx.req.param("category") ?? "") === "public"; const rootUrl = "https://acm.ecnu.edu.cn"; const currentUrl = `${rootUrl}/contest/`; const $ = load((await got_default(currentUrl)).data); const items = $("div > div > table > tbody > tr").filter((_, el) => !publicOnly || $(el).find("i").attr("class").includes("green")).toArray().map((el) => { const $tdList = $(el).find("td"); const title = $tdList.eq(0).text(); const startTime = $tdList.eq(1).text(); const duration = $tdList.eq(2).text(); const link = rootUrl + $tdList.find("a").eq(0).attr("href"); return { title, description: art(path.join(__dirname, "templates/description-067c2866.art"), { title, startTime, duration }), link }; }); return { title: `ECNU ACM ${publicOnly ? "公开" : ""}比赛`, link: currentUrl, item: items }; } //#endregion export { route };