rsshub
Version:
Make RSS Great Again!
65 lines (59 loc) • 2.43 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 "./got-KxxWdaxq.mjs";
import { t as invalid_parameter_default } from "./invalid-parameter-rr4AgGpp.mjs";
import { a as parseItem, i as getProviderList, o as parseList, t as getArchive } from "./utils-Di9BPU21.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 invalid_parameter_default(`Unknown region: ${region}`);
const limit = ctx.req.query("limit") ? Number.parseInt(ctx.req.query("limit"), 10) : 20;
const provider = (await getProviderList(region, cache_default.tryGet)).find((p) => p.key === providerId);
const list = parseList(region, await getArchive(region, limit, null, providerId));
const items = await Promise.all(list.map((item) => parseItem(item, cache_default.tryGet)));
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 };