rsshub
Version:
Make RSS Great Again!
64 lines (63 loc) • 2.01 kB
JavaScript
import { t as rofetch } from "./ofetch-eUBdfMpp.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 dayjs from "dayjs";
import { load } from "cheerio";
import utc from "dayjs/plugin/utc.js";
//#region lib/routes/cug/news.ts
dayjs.extend(utc);
const route = {
path: "/news",
categories: ["university"],
example: "/cug/news",
radar: [{ source: ["esearch.cug.edu.cn"] }],
name: "今日文章 - 包含全校网站最新通知",
maintainers: ["Doradx"],
handler,
url: "esearch.cug.edu.cn"
};
async function handler() {
const host = "https://esearch.cug.edu.cn";
const now = dayjs().utcOffset(8);
const results = (await Promise.all([0, 1].map((day) => rofetch(`${host}/ai_service/search-server/needle/search`, {
method: "POST",
body: {
aliasName: "collection_data",
searchDateType: "custom",
keyWord: "",
searchOperator: 0,
channelId: "comprehensive",
page: {
current: 0,
size: 10
},
searchScope: 3,
orderType: "date",
searchAggregation: false,
fragmentSize: 40,
rangeFilter: [{
start: now.subtract(day + 1, "day").format("YYYY-MM-DD HH:mm:ss"),
end: now.subtract(day, "day").format("YYYY-MM-DD HH:mm:ss"),
fieldName: "publishTime"
}]
}
})))).flatMap((response) => response.data.page.records).map((item) => ({
title: item.title,
link: item.url.replace("http:", "https:"),
pubDate: timezone(parseDate(item.publishTime), 8),
author: item.seedInfo?.seedName,
description: item.html
}));
return {
title: "CUG-今日文章",
link: host,
description: "中国地质大学(武汉) 每日文章,几乎包含全校站点最新信息。",
item: await Promise.all(results.map((item) => cache_default.tryGet(item.link, async () => {
item.description = load(await rofetch(item.link))(".v_news_content").html() ?? item.description;
return item;
})))
};
}
//#endregion
export { route };