rsshub
Version:
Make RSS Great Again!
61 lines (59 loc) • 2.31 kB
JavaScript
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import "./dist-BInvbO1W.mjs";
import "./logger-Czu8UMNd.mjs";
import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as cache_default } from "./cache-Bo__VnGm.mjs";
import { t as art } from "./render-BQo6B4tL.mjs";
import { t as timezone } from "./timezone-D8cuwzTY.mjs";
import path from "node:path";
import { load } from "cheerio";
//#region lib/routes/nhk/news-web-easy.ts
init_esm_shims();
const route = {
path: "/news_web_easy",
categories: ["traditional-media"],
example: "/nhk/news_web_easy",
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{ source: ["www3.nhk.or.jp/news/easy/", "www3.nhk.or.jp/"] }],
name: "News Web Easy",
maintainers: ["Andiedie"],
handler,
url: "www3.nhk.or.jp/news/easy/"
};
async function handler(ctx) {
const dates = (await ofetch_default("https://www3.nhk.or.jp/news/easy/news-list.json"))[0];
let items = Object.values(dates).flatMap((articles) => articles.map((article) => ({
title: article.title,
description: art(path.join(__dirname, "templates/news_web_easy-ee3cb891.art"), {
title: article.title_with_ruby,
image: article.news_web_image_uri
}),
guid: article.news_id,
pubDate: timezone(parseDate(article.news_prearranged_time), 9),
link: `https://www3.nhk.or.jp/news/easy/${article.news_id}/${article.news_id}.html`
})));
items = items.toSorted((a, b) => b.pubDate - a.pubDate).slice(0, ctx.req.query("limit") ? Number(ctx.req.query("limit")) : 30);
items = await Promise.all(items.map((item) => cache_default.tryGet(item.link, async () => {
const $ = load(await ofetch_default(item.link));
item.description += $(".article-body").html();
return item;
})));
return {
title: "NEWS WEB EASY",
link: "https://www3.nhk.or.jp/news/easy/",
description: "NEWS WEB EASYは、小学生・中学生の皆さんや、日本に住んでいる外国人のみなさんに、わかりやすいことば でニュースを伝えるウェブサイトです。",
item: items
};
}
//#endregion
export { route };