rsshub
Version:
Make RSS Great Again!
64 lines (62 loc) • 2.02 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 { t as cache_default } from "./cache-Bo__VnGm.mjs";
import "./helpers-DxBp0Pty.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { load } from "cheerio";
//#region lib/routes/v1tx/index.ts
const route = {
path: "/",
radar: [{
source: ["v1tx.com/"],
target: ""
}],
name: "Unknown",
maintainers: ["TonyRL"],
handler,
url: "v1tx.com/"
};
async function handler() {
const baseUrl = "https://www.v1tx.com";
const { data: response } = await got_default(baseUrl);
const $ = load(response);
const list = $("h2.entry-title a").toArray().map((item) => {
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 { data: response$1 } = await got_default(item.link);
const $$1 = load(response$1);
const data = JSON.parse($$1("script[type=\"application/ld+json\"]").text());
$$1(".entry-content figure > picture > source, noscript").remove();
$$1(".entry-content img").each((_, img) => {
if (img.attribs.src.startsWith("data:")) {
img.attribs.src = img.attribs["data-lazy-src"];
delete img.attribs["data-lazy-src"];
delete img.attribs["data-lazy-srcset"];
}
img.attribs.src = img.attribs.src.replace(/-1024x\d+\.jpg/, ".webp").replace(".jpg", ".webp");
delete img.attribs.srcset;
});
item.pubDate = parseDate(data.datePublished);
item.updated = parseDate(data.dateModified);
item.description = $$1(".entry-content").html();
return item;
})));
return {
title: $("head title").text(),
description: $("head meta[name=\"description\"]").attr("content"),
link: baseUrl,
image: `${baseUrl}/wp-content/uploads/2018/10/cropped-Favicon.webp`,
item: items
};
}
//#endregion
export { route };