rsshub
Version:
Make RSS Great Again!
59 lines (57 loc) • 1.76 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 "./helpers-DxBp0Pty.mjs";
import { r as getSubPath } from "./common-utils-vrWQFAEk.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/bad/index.ts
const route = {
path: "*",
name: "Unknown",
maintainers: [],
handler
};
async function handler(ctx) {
const currentUrl = `https://bad.news${getSubPath(ctx) === "/" ? "" : getSubPath(ctx)}`;
const $ = load((await got_default({
method: "get",
url: currentUrl
})).data);
$(".option, .pagination").remove();
const items = $(".entry").toArray().map((item) => {
item = $(item);
const a = item.find("a.title");
item.find("img").each(function() {
$(this).attr("src", $(this).attr("data-echo"));
$(this).removeClass("lazy");
$(this).removeAttr("data-echo");
$(this).removeAttr("id");
});
item.find("video").each(function() {
$(this).attr("poster", $(this).attr("data-echo"));
$(this).removeAttr("data-echo");
$(this).removeAttr("onerror");
$(this).removeAttr("id");
});
return {
title: a.text(),
link: a.attr("href"),
description: item.find(".coverdiv").html(),
author: item.find(".author").text().trim(),
pubDate: timezone(parseDate(item.find("time").attr("datetime")), 8),
category: item.find(".label").toArray().map((l) => $(l).text().trim())
};
});
return {
title: `Bad.news - ${$(".active").text()}${$(".selected").text()}`,
link: currentUrl,
item: items
};
}
//#endregion
export { route };