rsshub
Version:
Make RSS Great Again!
52 lines (47 loc) • 2.03 kB
JavaScript
import { t as InvalidParameterError } from "./invalid-parameter-CGxhjomn.mjs";
import { a as parseList, i as parseItem, r as getProviderList, t as getArchive } from "./utils-B4L2dnSQ.mjs";
//#region lib/routes/yahoo/news/provider.ts
const route = {
path: "/news/provider/:region/:providerId",
categories: ["new-media"],
example: "/yahoo/news/provider/tw/yahoo_tech_tw_942",
parameters: {
region: "地區, hk 或 tw, 分别表示香港雅虎和台湾雅虎",
providerId: "新聞來源 ID, 可透過路由\"新聞來源列表\"獲得"
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["hk.news.yahoo.com/"] }, { source: ["tw.news.yahoo.com/"] }],
name: "新聞來源",
maintainers: ["TonyRL", "williamgateszhao"],
handler,
description: `\`Region\`
| 香港 | 台灣 |
| ---- | ---- |
| hk | tw |
\`ProviderId\`
除了可以通过路由 "新聞來源列表" 获得外,也可通过 hk.news.yahoo.com/archive 和 tw\\.news.yahoo.com/archive 选择 "新闻来源" 后通过页面 Url 来获得。
例如 hk.news.yahoo.com/yahoo\\_movies\\_hk\\_660-- 所有分類 /archive, \`yahoo_movies_hk_660\` 就是 ProviderId 。`
};
async function handler(ctx) {
const { region, providerId } = ctx.req.param();
if (!["hk", "tw"].includes(region)) throw new InvalidParameterError(`Unknown region: ${region}`);
const limit = ctx.req.query("limit") ? Number(ctx.req.query("limit")) : 20;
const provider = (await getProviderList(region)).find((p) => p.key === providerId);
const list = parseList(region, await getArchive(region, limit, [], providerId));
const items = await Promise.all(list.map((item) => parseItem(item)));
return {
title: `Yahoo 新聞 - ${provider?.title ?? ""}`,
link: provider?.link ?? `https://${region}.news.yahoo.com`,
image: "https://s.yimg.com/cv/apiv2/social/images/yahoo_default_logo-1200x1200.png",
item: items
};
}
//#endregion
export { route };