rsshub
Version:
Make RSS Great Again!
82 lines (81 loc) • 2.9 kB
JavaScript
import { t as rofetch } from "./ofetch-eUBdfMpp.mjs";
import { t as parseDate } from "./parse-date-CjhZE69i.mjs";
import { t as cache_default } from "./cache-CiDoUSLo.mjs";
import { t as timezone } from "./timezone-DE--ze1V.mjs";
import { load } from "cheerio";
//#region lib/routes/br-klassik/utils.ts
const baseUrl$1 = "https://www.br-klassik.de";
const getList = async (path) => {
const $ = load(await rofetch(`${baseUrl$1}${path}`));
return $(".br-teaser a.br-internal").toArray().map((elem) => {
const $elem = $(elem);
const href = $elem.attr("href");
if (!href || !href.endsWith("-100.html")) return;
const headline = $elem.find("h4.br-headline").text().trim();
const title = $elem.find("p.br-title").text().trim();
const description = $elem.find("p.br-text").text().trim();
return {
link: new URL(href, baseUrl$1).href,
title: [headline, title].filter(Boolean).join(": "),
description
};
}).filter((item) => item !== void 0);
};
const getArticle = ({ link, title, description }) => cache_default.tryGet(link, async () => {
const $ = load(await rofetch(link));
const authorDate = $(".br-authordate").text().trim();
const dateMatch = authorDate.match(/\d{2}\.\d{2}\.\d{4}/);
const pubDate = dateMatch ? timezone(parseDate(dateMatch[0], "DD.MM.YYYY"), 1) : void 0;
const authorMatch = authorDate.match(/von\s+(\S.*)$/);
const author = authorMatch ? authorMatch[1].trim() : void 0;
const $article = $(".br-article");
$article.find(".br-head, .br-audio, .br-textbox, .br-social-footer, .br-comments, .br-footer, script, style, .br-info, .br-credits, .br-social, .br-author-links").remove();
$article.find("p").filter((_, elem) => {
const text = $(elem).text();
return text.includes("Autorin des Artikels") || text.includes("Autor des Artikels");
}).remove();
return {
title,
link,
description: $article.html()?.replaceAll(/\s+/g, " ").trim() || description,
pubDate,
author
};
});
//#endregion
//#region lib/routes/br-klassik/aktuell.ts
const baseUrl = "https://www.br-klassik.de";
const route = {
path: "/aktuell",
categories: ["traditional-media"],
example: "/br-klassik/aktuell",
parameters: {},
features: {
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
requireConfig: false
},
name: "Aktuell (News & Kritik)",
maintainers: ["wongJG"],
handler,
description: "News und Kritik aus der Welt der Klassischen Musik.",
radar: [{
source: ["www.br-klassik.de/aktuell/index.html"],
target: "/aktuell"
}]
};
async function handler() {
const list = await getList("/aktuell/index.html");
const items = await Promise.all(list.map((item) => getArticle(item)));
return {
title: "BR-Klassik | Aktuell",
link: `${baseUrl}/aktuell/index.html`,
description: "News und Kritik aus der Welt der Klassischen Musik",
item: items
};
}
//#endregion
export { route };