rsshub
Version:
Make RSS Great Again!
50 lines (48 loc) • 1.57 kB
JavaScript
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 { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import "./render-BQo6B4tL.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import "./invalid-parameter-rr4AgGpp.mjs";
import { n as parseItem, r as parseList } from "./utils-B39rTCxS.mjs";
//#region lib/routes/4gamers/tag.ts
const route = {
path: "/tag/:tag",
categories: ["game"],
example: "/4gamers/tag/限時免費",
parameters: { tag: "标签名,可在标签 URL 中找到" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["www.4gamers.com.tw/news/tag/:tag"] }],
name: "标签",
maintainers: ["hoilc"],
handler,
url: "www.4gamers.com.tw/news"
};
async function handler(ctx) {
const tag = ctx.req.param("tag");
const { data: response } = await got_default(`https://www.4gamers.com.tw/site/api/news/by-tag`, { searchParams: {
tag,
pageSize: ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit")) : 25
} });
const list = parseList(response.data.results);
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, () => parseItem(item))));
return {
title: `4Gamers - #${tag}`,
link: `https://www.4gamers.com.tw/news/tag/${tag}`,
item: items
};
}
//#endregion
export { route };