UNPKG

rsshub

Version:
63 lines (61 loc) 2.01 kB
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 "./md5-C8GRvctM.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import { n as header } from "./utils-Vxf_K345.mjs"; //#region lib/routes/zhihu/daily-section.ts const route = { path: "/daily/section/:sectionId", categories: ["social-media"], example: "/zhihu/daily/section/2", parameters: { sectionId: "合集 id,可在 https://news-at.zhihu.com/api/7/sections 找到" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: true, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["daily.zhihu.com/*"], target: "/daily" }], name: "知乎日报 - 合集", maintainers: ["ccbikai"], handler, url: "daily.zhihu.com/*" }; async function handler(ctx) { const sectionId = ctx.req.param("sectionId"); const listRes = await ofetch_default(`https://news-at.zhihu.com/api/7/section/${sectionId}`, { headers: { ...header, Referer: `https://news-at.zhihu.com/api/7/section/${sectionId}` } }); const storyList = listRes.stories.filter((el) => el.url.startsWith("https://daily.zhihu.com/")); const resultItem = await Promise.all(storyList.map(async (story) => { const url = "https://news-at.zhihu.com/api/7/news/" + story.id; const storyJson = await cache_default.tryGet(url, async () => { return await ofetch_default(url); }); return { title: storyJson.title, description: storyJson.body, link: storyJson.url, pubDate: parseDate(storyJson.publish_time, "X") }; })); return { title: `${listRes.name} - 知乎日报`, link: "https://daily.zhihu.com", description: "每天3次,每次7分钟", image: "http://static.daily.zhihu.com/img/new_home_v3/mobile_top_logo.png", item: resultItem }; } //#endregion export { route };