Files
RSSHub/lib/v2/nhentai/search.js
T
2023-03-25 01:33:15 +08:00

24 lines
657 B
JavaScript

const { getSimple, getDetails, getTorrents } = require('./util');
module.exports = async (ctx) => {
const { keyword, mode } = ctx.params;
const url = `https://nhentai.net/search/?q=${keyword}`;
const simples = await getSimple(url);
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 5;
let items = simples;
if (mode === 'detail') {
items = await getDetails(ctx.cache, simples, limit);
} else if (mode === 'torrent') {
items = await getTorrents(ctx.cache, simples, limit);
}
ctx.state.data = {
title: `nhentai - search - ${keyword}`,
link: url,
item: items,
};
};