rsshub
Version:
Make RSS Great Again!
70 lines (68 loc) • 1.99 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import "./render-BQo6B4tL.mjs";
import "./timezone-D8cuwzTY.mjs";
import { r as rootUrl, t as buildApiUrl } from "./util-BZJAO1yJ.mjs";
import { load } from "cheerio";
//#region lib/routes/aibase/news.ts
const route = {
path: "/news",
name: "资讯",
url: "www.aibase.com",
maintainers: ["zreo0"],
handler: async (ctx) => {
const limit = Number.parseInt(ctx.req.query("limit") ?? "30", 10);
const currentUrl = new URL("discover", rootUrl).href;
const $ = load(await ofetch_default(currentUrl));
const logoSrc = $("img.logo").prop("src");
const image = logoSrc ? new URL(logoSrc, rootUrl).href : "";
const author = $("title").text().split(/_/).pop();
const { apiInfoListUrl } = await buildApiUrl($);
return {
title: "AI新闻资讯",
description: "AI新闻资讯 - 不错过全球AI革新的每一个时刻",
language: "zh-cn",
link: "https://www.aibase.com/zh/news",
item: (await ofetch_default(apiInfoListUrl, {
headers: { accept: "application/json;charset=utf-8" },
query: {
pagesize: limit,
page: 1,
type: 1,
isen: 0
}
})).map((item) => ({
title: item.title,
link: `https://www.aibase.com/zh/news/${item.Id}`,
description: item.summary,
pubDate: parseDate(item.addtime),
author: item.author || "AI Base"
})),
allowEmpty: true,
image,
author
};
},
example: "/aibase/news",
description: "获取 AI 资讯列表",
categories: ["new-media"],
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportRadar: true,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{
source: ["www.aibase.com/zh/news"],
target: "/news"
}]
};
//#endregion
export { route };