rsshub
Version:
Make RSS Great Again!
58 lines (56 loc) • 1.73 kB
JavaScript
import "./dist-Bog6z_OM.mjs";
import "./config-MQ-7ebJ_.mjs";
import "./logger-C4avouvV.mjs";
import "./ofetch-DKl_Ma9g.mjs";
import { t as parseDate } from "./parse-date-r5WDWHno.mjs";
import "./helpers-Bo4JQYdN.mjs";
import { r as getSubPath } from "./common-utils-Cz5bFBus.mjs";
import { t as got_default } from "./got-CO-ndVl2.mjs";
import { t as timezone } from "./timezone-CA9Huotp.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 };