rsshub
Version:
Make RSS Great Again!
80 lines (78 loc) • 2.41 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 { t as cache_default } from "./cache-Bo__VnGm.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/daily.ts
const route = {
path: "/daily",
name: "AI日报",
url: "www.aibase.com",
maintainers: ["3tuuu"],
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 = "AI Base";
const { aILogListUrl } = await buildApiUrl($);
const response = await ofetch_default(aILogListUrl, {
headers: { accept: "application/json;charset=utf-8" },
query: {
pagesize: limit,
page: 1,
type: 2,
isen: 0
}
});
if (!response || !response.data) throw new Error("日报数据不存在或为空");
return {
title: "AI日报",
description: "每天三分钟关注AI行业趋势",
language: "zh-cn",
link: "https://www.aibase.com/zh/daily",
item: await Promise.all(response.data.slice(0, limit).map(async (item) => {
const articleUrl = `https://www.aibase.com/zh/news/${item.Id}`;
return await cache_default.tryGet(articleUrl, async () => {
const description = load(await ofetch_default(articleUrl))(".post-content").html();
if (!description) throw new Error(`Empty content: ${articleUrl}`);
return {
title: item.title,
link: articleUrl,
description,
pubDate: parseDate(item.addtime),
author: "AI Base"
};
});
})),
allowEmpty: true,
image,
author
};
},
example: "/aibase/daily",
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/daily"],
target: "/daily"
}]
};
//#endregion
export { route };