UNPKG

rsshub

Version:
58 lines (56 loc) 2.02 kB
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import { t as parseDate } from "./parse-date-BrP7mxXf.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import "./helpers-DxBp0Pty.mjs"; import { t as art } from "./render-BQo6B4tL.mjs"; import { t as got_default } from "./got-KxxWdaxq.mjs"; import path from "node:path"; //#region lib/routes/loltw/news.ts init_esm_shims(); const route = { path: "/news/:category?", categories: ["game"], example: "/loltw/news", parameters: { category: "新闻分类,置空为全部新闻" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "台服新闻", maintainers: ["hoilc"], handler, description: `| 活动 | 资讯 | 系统 | 电竞 | 版本资讯 | 战棋资讯 | | ----- | ---- | ------ | ------ | -------- | -------- | | event | info | system | esport | patch | TFTpatch |` }; async function handler(ctx) { const category = ctx.req.param("category") ?? ""; const baseUrl = "https://lol.garena.tw"; const list = (await got_default(`${baseUrl}/api/news/search?category=${category}`)).data.data.news.map((item) => ({ guid: item.id, title: item.title, author: "Garena", link: `${baseUrl}/news/articles/${item.id}`, pubDate: parseDate(item.updated_at * 1e3) })); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const detailResponse = await got_default(`${baseUrl}/api/news/detail?news_id=${item.guid}`); item.description = art(path.join(__dirname, "templates/news-b5d6de3e.art"), detailResponse.data.data.news_detail); return item; }))); return { title: "英雄联盟 - 台服新闻", link: category ? `${baseUrl}/news/${category}` : `${baseUrl}/news`, item: items }; } //#endregion export { route };