rsshub
Version:
Make RSS Great Again!
40 lines (39 loc) • 1.5 kB
JavaScript
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";
//#region lib/routes/youdao/latest.ts
const route = {
path: "/latest",
categories: ["study"],
example: "/youdao/latest",
name: "笔记最新动态",
maintainers: ["nczitzk"],
handler
};
async function handler() {
const rootUrl = "https://xueba.youdao.com";
const list = (await rofetch(`${rootUrl}/yws/mapi/xueba/library?method=realTimeCollect&count=10`, {
headers: { Referer: `${rootUrl}/web/index.html` },
parseResponse: JSON.parse
})).Clt.map((item) => ({
title: `${item.name} 保存了 ${item.title}`,
pubDate: parseDate(item.time),
link: `https://note.youdao.com/publicshare/?id=${item.shareKey}`
}));
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const id = item.link.split("?id=", 2)[1];
try {
item.description = (await rofetch(`https://note.youdao.com/yws/public/notebook/${id}`, { parseResponse: JSON.parse }))[2].map((note) => `<h3><a href="https://note.youdao.com/publicshare?id=${id}#${note.p}">${note.tl}</a></h3>`).join("");
} catch {
item.description = (await rofetch(`https://note.youdao.com/yws/public/note/${id}`, { parseResponse: JSON.parse })).content;
}
return item;
})));
return {
title: "笔记最新动态 - 有道云笔记",
link: `${rootUrl}/web/index.html`,
item: items
};
}
//#endregion
export { route };