rsshub
Version:
Make RSS Great Again!
62 lines (60 loc) • 2.34 kB
JavaScript
import "./esm-shims-CzJ_djXG.mjs";
import { t as config } from "./config-C37vj7VH.mjs";
import { t as ViewType } from "./types-D84BRIt4.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 "./render-BQo6B4tL.mjs";
import { t as got_default } from "./got-KxxWdaxq.mjs";
import { a as renderDescription, t as defaultDomain } from "./utils-BTaTkcFQ.mjs";
//#region lib/routes/pornhub/category.ts
const route = {
path: "/category/:caty",
categories: ["multimedia"],
view: ViewType.Videos,
example: "/pornhub/category/popular-with-women",
parameters: { caty: "category, see [categories](https://www.pornhub.com/webmasters/categories)" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
nsfw: true
},
name: "Category",
maintainers: ["nczitzk"],
handler
};
async function handler(ctx) {
const category = ctx.req.param("caty");
const categories = await cache_default.tryGet("pornhub:categories", async () => {
const { data } = await got_default(`${defaultDomain}/webmasters/categories`);
return data.categories;
});
const categoryId = Number.isNaN(category) ? categories.find((item) => item.category === category)?.id : category;
const categoryName = Number.isNaN(category) ? category : categories.find((item) => item.id === Number.parseInt(category)).category;
const response = await cache_default.tryGet(`pornhub:category:${categoryName}`, async () => {
const { data } = await got_default(`${defaultDomain}/webmasters/search?category=${categoryName}`);
return data;
}, config.cache.routeExpire, false);
if (response.code) throw new Error(response.message);
const list = response.videos.map((item) => ({
title: item.title,
link: item.url,
description: renderDescription({ thumbs: item.thumbs }),
pubDate: parseDate(item.publish_date),
category: [...new Set([...item.tags.map((t) => t.tag_name), ...item.categories.map((c) => c.category)])]
}));
return {
title: `Pornhub - ${categoryName}`,
link: `${defaultDomain}/video?c=${categoryId}`,
item: list
};
}
//#endregion
export { route };