rsshub
Version:
Make RSS Great Again!
110 lines (107 loc) • 2.8 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import { t as ViewType } from "./types-D84BRIt4.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs";
import "./parse-date-BrP7mxXf.mjs";
import "./cache-Bo__VnGm.mjs";
import "./render-BQo6B4tL.mjs";
import { n as baseUrl, t as ProcessItems } from "./util-Ww8bKYMw.mjs";
import { load } from "cheerio";
//#region lib/routes/dgtle/news.ts
const handler = async (ctx) => {
const { id = "0" } = ctx.req.param();
const limit = Number.parseInt(ctx.req.query("limit") ?? "30", 10);
const targetUrl = new URL("news", baseUrl).href;
const apiUrl = new URL(`news/getNewsIndexList/${id}`, baseUrl).href;
const $ = load(await ofetch_default(targetUrl));
const language = $("html").attr("lang") ?? "zh-CN";
const items = await ProcessItems(limit, (await ofetch_default(apiUrl)).data.dataList);
const title = $(`div.whale_news_index-content-tab li[data_id="${id}"]`).text();
return {
title: `${$("title").text().trim().split(/\s/)[0]}${title ? ` - ${title}` : id}`,
description: $("meta[name=\"description\"]").attr("content"),
link: targetUrl,
item: items,
allowEmpty: true,
author: $("meta[name=\"keywords\"]").attr("content")?.split(/,/)[0] ?? void 0,
language,
id: targetUrl
};
};
const route = {
path: "/news/:id?",
name: "鲸闻",
url: "www.dgtle.com",
maintainers: ["nczitzk"],
handler,
example: "/dgtle/news/0",
parameters: { id: {
description: "分类,默认为 `0`,即最新,可在下表中找到",
options: [
{
label: "最新",
value: "0"
},
{
label: "直播",
value: "395"
},
{
label: "资讯",
value: "396"
},
{
label: "每日一言",
value: "388"
}
]
} },
description: `:::tip
订阅 [最新](https://www.dgtle.com/news),其对应分类 ID 为 \`0\`,此时路由为 [\`/dgtle/news/0\`](https://rsshub.app/dgtle/news/0)。
:::
| 最新 | 直播 | 资讯 | 每日一言 |
| ---- | ---- | ---- | -------- |
| 0 | 395 | 396 | 388 |
`,
categories: ["new-media"],
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportRadar: true,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [
{
source: ["www.dgtle.com/news"],
target: "/news"
},
{
title: "最新",
source: ["www.dgtle.com/news"],
target: "/news/0"
},
{
title: "直播",
source: ["www.dgtle.com/news"],
target: "/news/395"
},
{
title: "资讯",
source: ["www.dgtle.com/news"],
target: "/news/396"
},
{
title: "每日一言",
source: ["www.dgtle.com/news"],
target: "/news/388"
}
],
view: ViewType.Articles
};
//#endregion
export { handler, route };