UNPKG

rsshub

Version:
54 lines (52 loc) 1.76 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import "./logger-C4avouvV.mjs"; import "./ofetch-DKl_Ma9g.mjs"; import "./parse-date-r5WDWHno.mjs"; import "./is-worker-DESPicPc.mjs"; import "./cache-SV6W5EPy.mjs"; import "./helpers-Bo4JQYdN.mjs"; import { t as got_default } from "./got-CO-ndVl2.mjs"; import { t as invalid_parameter_default } from "./invalid-parameter-ByDtry1B.mjs"; import { n as parseList, t as parseItem } from "./utils-DQwY6EHu.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 };