UNPKG

rsshub

Version:
42 lines (40 loc) 1.64 kB
import { t as cache_default } from "./cache-BkqOokyU.mjs"; import { t as got_default } from "./got-BTowW50G.mjs"; import { t as getRssItem } from "./utils-BLQQjdJk.mjs"; //#region lib/routes/lifeweek/channel.ts const rootApiUrl = "https://www.lifeweek.com.cn/api/userWebFollow/getFollowTagContentList?type=3&sort=2&tagId"; const rootUrl = "https://www.lifeweek.com.cn/column"; const articleRootUrl = "https://www.lifeweek.com.cn/article"; const route = { path: "/channel/:id", categories: ["traditional-media"], example: "/lifeweek/channel/9", parameters: { id: "栏目 ID" }, description: `提取文章全文,获得更好的阅读体验。支持所有频道,频道名称见 [杂志栏目](https://www.lifeweek.com.cn/classify?type=2)。例如 [调查栏目](https://www.lifeweek.com.cn/column/9) URL 最后的数字为栏目 ID | 调查 | 热点 | 人物 | 社会 | 经济 | 文化 | | ---- | ---- | ---- | ---- | ---- | ---- | | 9 | 6 | 10 | 2 | 3 | 4 |`, radar: [{ source: ["lifeweek.com.cn/column/:channel"], target: "/channel/:channel" }], name: "栏目", maintainers: ["changren-wcr"], handler }; async function handler(ctx) { const channel = ctx.req.param("id"); const { data } = await got_default(`${rootApiUrl}=${channel}`); const result = data.model.articleResponseList; const items = await Promise.all(result.map((item) => { const articleLink = `${articleRootUrl}/${item.id}`; return cache_default.tryGet(articleLink, () => getRssItem(item, articleLink)); })); return { title: data.model.tagName, link: `${rootUrl}/${channel}`, item: items }; } //#endregion export { route };