rsshub
Version:
Make RSS Great Again!
83 lines (81 loc) • 2.52 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 { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { t as timezone } from "./timezone-D8cuwzTY.mjs";
import { load } from "cheerio";
//#region lib/routes/peopo/topic.ts
const baseUrl = "https://www.peopo.org";
const route = {
path: "/topic/:topicId?",
categories: ["new-media"],
example: "/peopo/topic/159",
parameters: { topicId: "分類 ID,見下表,默認為社會關懷" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{
source: ["peopo.org/topic/:topicId"],
target: "/topic/:topicId"
}],
name: "新聞分類",
maintainers: [],
handler,
description: `| 分類 | ID |
| -------- | --- |
| 社會關懷 | 159 |
| 生態環保 | 113 |
| 文化古蹟 | 143 |
| 社區改造 | 160 |
| 教育學習 | 161 |
| 農業 | 163 |
| 生活休閒 | 162 |
| 媒體觀察 | 164 |
| 運動科技 | 165 |
| 政治經濟 | 166 |
| 北台灣 | 223 |
| 中台灣 | 224 |
| 南台灣 | 225 |
| 東台灣 | 226 |
| 校園中心 | 167 |
| 原住民族 | 227 |
| 天然災害 | 168 |`
};
async function handler(ctx) {
const { topicId = "159" } = ctx.req.param();
const url = `${baseUrl}/topic/${topicId}`;
const $ = load((await got_default(url)).data);
const list = $(".view-list-title").toArray().map((item) => {
item = $(item);
return {
title: item.find("a").text(),
link: new URL(item.find("a").attr("href"), baseUrl).href
};
});
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const $$1 = load((await got_default(item.link)).data);
item.author = $$1("#user-info h3").text();
item.category = $$1("#node-terms .inline li").toArray().map((item$1) => $$1(item$1).find("a").text());
item.pubDate = timezone(parseDate($$1(".submitted span").text()), 8);
item.description = ($$1(".field-name-field-video-id .field-items").text() ? $$1(".field-name-field-video-id input").attr("value") : "") + $$1(".post_text_s .field-items").html();
return item;
})));
return {
title: $("head title").text(),
link: url,
language: "zh-TW",
item: items
};
}
//#endregion
export { route };