rsshub
Version:
Make RSS Great Again!
46 lines (45 loc) • 1.66 kB
JavaScript
import { t as cache_default } from "./cache-C1Y-9qDV.mjs";
import { t as got_default } from "./got-DUpa1V3-.mjs";
import { t as InvalidParameterError } from "./invalid-parameter-CGxhjomn.mjs";
import { n as SUB_URL, r as loadArticle, t as SUB_NAME_PREFIX } from "./const-Cgk98ZPd.mjs";
//#region lib/routes/everia/category.ts
const route = {
path: "/category/:category",
categories: ["picture"],
example: "/everia/category/cosplay",
parameters: { category: "Category of the image stream" },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
nsfw: true
},
radar: [{
source: ["everia.club/category/:category"],
target: "/category/:category"
}],
name: "Images with category",
maintainers: ["KTachibanaM", "AiraNadih"],
handler
};
async function handler(ctx) {
const limit = Number.parseInt(ctx.req.query("limit")) || 20;
const category = ctx.req.param("category");
const categoryUrl = `${SUB_URL}category/${category}/`;
const categoryId = await cache_default.tryGet(`everia:category:${category}`, async () => {
const { data: categories } = await got_default(`${SUB_URL}wp-json/wp/v2/categories?slug=${category}`);
if (!categories.length) throw new InvalidParameterError(`Category not found: ${category}`);
return categories[0].id;
});
const { data: posts } = await got_default(`${SUB_URL}wp-json/wp/v2/posts?categories=${categoryId}&per_page=${limit}&_embed`);
return {
title: `${SUB_NAME_PREFIX} - Category: ${category}`,
link: categoryUrl,
item: posts.map((post) => loadArticle(post))
};
}
//#endregion
export { route };