UNPKG

rsshub

Version:
54 lines (52 loc) 1.76 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import "./parse-date-BrP7mxXf.mjs"; import "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import { t as invalid_parameter_default } from "./invalid-parameter-rr4AgGpp.mjs"; import { n as parseList, t as parseItem } from "./utils-Bzn2CzGG.mjs"; //#region lib/routes/guokr/channel.ts const channelMap = { calendar: "pac", institute: "predator", foodlab: "predator", pretty: "beauty" }; const route = { path: "/column/:channel", categories: ["new-media"], example: "/guokr/column/calendar", parameters: { channel: "专栏类别" }, radar: [{ source: ["guokr.com/:channel"] }], name: "果壳网专栏", maintainers: ["DHPO", "hoilc"], handler, url: "guokr.com/", description: `| 物种日历 | 吃货研究所 | 美丽也是技术活 | | -------- | ---------- | -------------- | | calendar | institute | beauty |` }; async function handler(ctx) { const { data: response } = await got_default(`https://www.guokr.com/apis/minisite/article.json`, { searchParams: { retrieve_type: "by_wx", channel_key: channelMap[ctx.req.param("channel")] ?? ctx.req.param("channel"), offset: 0, limit: 10 } }); const result = parseList(response.result); if (result.length === 0) throw new invalid_parameter_default("Unknown channel"); const channelName = result[0].channels[0].name; const channelUrl = result[0].channels[0].url; const items = await Promise.all(result.map((item) => parseItem(item))); return { title: `果壳网 ${channelName}`, link: channelUrl, item: items }; } //#endregion export { route };