rsshub
Version:
Make RSS Great Again!
82 lines (71 loc) • 3.18 kB
JavaScript
import { t as rofetch } from "./ofetch-W1aeTHCo.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { load } from "cheerio";
//#region lib/routes/kenshin/index.ts
const route = {
path: "/:category?/:type?",
categories: ["blog"],
example: "/kenshin",
parameters: {
category: "分类,见下表,默认为首页",
type: "子分类,见下表,默认为首页"
},
name: "分类",
maintainers: ["nczitzk"],
description: `::: tip
如 \`藝能新聞\` 的 \`日劇新聞\` 分类,路由为 \`/jnews/news_drama\`
:::
藝能新聞 jnews
| 日劇新聞 | 日影新聞 | 日樂新聞 | 日藝新聞 |
| ----------- | ----------- | ----------- | ------------------- |
| news\\_drama | news\\_movie | news\\_music | news\\_entertainment |
| 動漫新聞 | 藝人美照 | 清涼寫真 | 日本廣告 | 其他日聞 |
| --------- | ------------ | ---------- | -------- | ------------ |
| news\\_acg | artist-photo | photoalbum | jpcm | news\\_others |
旅遊情報 jpnews
| 日本美食情報 | 日本甜點情報 | 日本零食情報 | 日本飲品情報 | 日本景點情報 |
| ------------ | ------------- | ------------- | ------------- | ------------------ |
| jpnews-food | jpnews-sweets | jpnews-okashi | jpnews-drinks | jpnews-attractions |
| 日本玩樂情報 | 日本住宿情報 | 日本活動情報 | 日本購物情報 | 日本社會情報 |
| ------------ | ------------ | ------------- | --------------- | -------------- |
| jpnews-play | jpnews-hotel | jpnews-events | jpnews-shopping | jpnews-society |
| 日本交通情報 | 日本天氣情報 |
| -------------- | -------------- |
| jpnews-traffic | jpnews-weather |
日劇世界 jdrama
| 每周劇評 | 日劇總評 | 資料情報 |
| --------------------- | -------------------- | ----------- |
| drama\\_review\\_weekly | drama\\_review\\_final | drama\\_data |
| 深度日劇 | 收視報告 | 日劇專欄 | 劇迷互動 |
| ----------- | ------------- | ------------- | ------------------ |
| drama\\_deep | drama\\_rating | drama\\_column | drama\\_interactive |`,
handler
};
async function handler(ctx) {
const { category = "", type = "" } = ctx.req.param();
const currentUrl = `https://kenshin.hk${category && type ? `/category/${category}/${type}` : ""}`;
const $ = load(await rofetch(currentUrl));
const list = $(".entry-title a").toArray().slice(0, 10).map((item) => {
const $item = $(item);
return {
title: $item.text(),
link: $item.attr("href")
};
});
const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const content = load(await rofetch(item.link));
content(".fb-comments").prev().remove();
content(".code-block, .fb-comments").remove();
item.description = content(".entry-content").html();
item.pubDate = parseDate(content("meta[property=\"article:published_time\"]").attr("content"));
return item;
})));
return {
title: $("title").text(),
link: currentUrl,
item: items
};
}
//#endregion
export { route };