rsshub
Version:
Make RSS Great Again!
131 lines (129 loc) • 4.31 kB
JavaScript
import { n as init_esm_shims, t as __dirname } from "./esm-shims-CzJ_djXG.mjs";
import "./config-C37vj7VH.mjs";
import { t as ViewType } from "./types-D84BRIt4.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 path from "node:path";
import { load } from "cheerio";
//#region lib/routes/0xxx/index.ts
init_esm_shims();
const handler = async (ctx) => {
const { filter } = ctx.req.param();
const limit = Number.parseInt(ctx.req.query("limit") ?? "100", 10);
const baseUrl = "https://0xxx.ws";
const targetUrl = new URL(filter ? `?${filter}` : "", baseUrl).href;
const $ = load(await ofetch_default(targetUrl));
const language = $("html").attr("lang") ?? "en";
let items = [];
items = $("table#home-table tr:not(.gore)").slice(0, limit).toArray().map((el) => {
const $el = $(el);
const $categoryEl = $el.find("td.category");
const $catalogueEl = $el.find("td.catalogue");
const $dateEl = $el.find("td.date");
const title$1 = $el.find("td.title").text();
const image = $el.find("a.screenshot").attr("rel");
const description = art(path.join(__dirname, "templates/description-4206d5b5.art"), {
images: image ? [{
src: image,
alt: title$1
}] : void 0,
category: $categoryEl.html(),
catalogue: $catalogueEl.html(),
title: title$1,
size: $el.find("td.size").text(),
date: $dateEl.html()
});
const pubDateStr = $dateEl.text();
const linkUrl = $el.find("td.title a").attr("href");
const categories = [...new Set([
$categoryEl.text()?.trim(),
$catalogueEl.text()?.trim(),
$dateEl.text()
])].filter((c) => Boolean(c && c !== "-"));
const upDatedStr = pubDateStr;
return {
title: title$1,
description,
pubDate: pubDateStr ? parseDate(pubDateStr, "DD.MM.YYYY") : void 0,
link: linkUrl ? new URL(linkUrl, baseUrl).href : void 0,
category: categories,
content: {
html: description,
text: description
},
image,
banner: image,
updated: upDatedStr ? parseDate(upDatedStr, "DD.MM.YYYY") : void 0,
language
};
});
items = await Promise.all(items.map((item) => {
if (!item.link) return item;
return cache_default.tryGet(item.link, async () => {
const $$ = load(await ofetch_default(item.link));
const description = art(path.join(__dirname, "templates/description-4206d5b5.art"), { images: $$("div.thumbs img").toArray().map((i) => {
const $i = $$(i);
return {
src: $i.attr("src"),
alt: $i.attr("alt") ?? item.title
};
}) }) + (item.description ?? "");
return {
...item,
description
};
});
}));
const title = $("title").text()?.split(/\|/).pop();
return {
title: title ? `${title} - ${filter}` : filter,
description: $("meta[name=\"description\"]").attr("content"),
link: targetUrl,
item: items,
allowEmpty: true,
image: $("div.logo img").attr("src") ? new URL($("div.logo img").attr("src"), baseUrl).href : void 0,
author: $("meta[property=\"og:site_name\"]").attr("content"),
language,
id: targetUrl
};
};
const route = {
path: "/:filter?",
name: "Source",
url: "0xxx.ws",
maintainers: ["nczitzk"],
handler,
example: "/0xxx/category=Movie-HD-1080p",
parameters: { filter: { description: "Filter" } },
description: `:::tip
To subscribe to [Movie HD 1080p](https://0xxx.ws?category=Movie-HD-1080p), where the source URL is \`https://0xxx.ws?category=Movie-HD-1080p\`, extract the certain parts from this URL to be used as parameters, resulting in the route as [\`/0xxx/category=Movie-HD-1080p\`](https://rsshub.app/0xxx/category=Movie-HD-1080p).
:::
`,
categories: ["multimedia"],
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportRadar: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
nfsw: true
},
radar: [{
source: ["0xxx.ws"],
target: (_, url) => {
const urlObj = new URL(url);
urlObj.searchParams.delete("next");
const filter = urlObj.searchParams.toString();
return `/0xxx${filter ? `/${filter}` : ""}`;
}
}],
view: ViewType.Articles
};
//#endregion
export { handler, route };