UNPKG

rsshub

Version:
55 lines (53 loc) 1.46 kB
import "./dist-Bog6z_OM.mjs"; import "./config-MQ-7ebJ_.mjs"; import { t as ViewType } from "./types-gOySfSXJ.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 { t as rss_parser_default } from "./rss-parser-Cnh4NKwh.mjs"; import { t as fetchArticle } from "./utils-BCQ2SQer.mjs"; //#region lib/routes/apnews/rss.ts const HOME_PAGE = "https://apnews.com"; const route = { path: "/rss/:category?", categories: ["traditional-media"], example: "/apnews/rss/business", view: ViewType.Articles, parameters: { category: { description: "Category from the first segment of the corresponding site, or `index` for the front page.", default: "index" } }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["apnews.com/:rss"], target: "/rss/:rss" }], name: "News", maintainers: [ "zoenglinghou", "mjysci", "TonyRL" ], handler }; async function handler(ctx) { const { rss = "index" } = ctx.req.param(); const url = `${HOME_PAGE}/${rss}.rss`; const res = await rss_parser_default.parseURL(url); const items = ctx.req.query("fulltext") === "true" ? await Promise.all(res.items.map((item) => fetchArticle(item))) : res; return { ...res, item: items }; } //#endregion export { route };