fix(route): nhentai (#15661)

* fix(route): nhentai

* fix: typo
This commit is contained in:
Tony 2024-05-22 16:24:48 +08:00 committed by GitHub
parent 57afba4dc2
commit f9003f910b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 20 deletions

View File

@ -6,26 +6,21 @@ import InvalidParameterError from '@/errors/types/invalid-parameter';
const supportedKeys = new Set(['parody', 'character', 'tag', 'artist', 'group', 'language', 'category']);
export const route: Route = {
path: '/:key/:keyword/:mode?',
categories: ['anime'],
example: '/nhentai/language/chinese',
path: '/index/:key/:keyword/:mode?',
example: '/nhentai/index/language/chinese',
parameters: {
key: 'Filter term, can be: `parody`, `character`, `tag`, `artist`, `group`, `language` or `category`',
keyword: 'Filter value',
mode: 'mode, `simple` to only show cover, `detail` to show all pages, `torrent` to include Magnet URI, need login, refer to [Route-specific Configurations](https://docs.rsshub.app/deploy/config#route-specific-configurations), default to `simple`',
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportBT: true,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['nhentai.net/:key/:keyword'],
target: '/:key/:keyword',
target: '/index/:key/:keyword',
},
],
name: 'Filter',

View File

@ -3,4 +3,5 @@ import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: 'nhentai',
url: 'nhentai.net',
categories: ['anime'],
};

View File

@ -4,19 +4,14 @@ import { getSimple, getDetails, getTorrents } from './util';
export const route: Route = {
path: '/search/:keyword/:mode?',
categories: ['anime'],
example: '/nhentai/search/language%3Ajapanese+-scat+-yaoi+-guro+-"mosaic+censorship"',
parameters: {
keyword: 'Keywords for search. You can copy the content after `q=` after searching on the original website, or you can enter it directly. See the [official website](https://nhentai.net/info/) for details',
mode: 'mode, `simple` to only show cover, `detail` to show all pages, `torrent` to include Magnet URI, need login, refer to [Route-specific Configurations](https://docs.rsshub.app/deploy/config#route-specific-configurations), default to `simple`',
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportBT: true,
supportPodcast: false,
supportScihub: false,
},
radar: [
{

View File

@ -3,6 +3,7 @@ const __dirname = getCurrentPath(import.meta.url);
import { load } from 'cheerio';
import got from '@/utils/got';
import ofetch from '@/utils/ofetch';
import { config } from '@/config';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
@ -67,9 +68,8 @@ const getCookie = async (username, password, cache) => {
return userTokenCookie;
};
const gotByIp = (url, ...options) =>
// credit: https://github.com/sinkaroid/jandapress/pull/23
got(url.replace(/^https:\/\/nhentai.net\//, 'http://129.150.63.211:3002/'), {
const oFetch = (url, ...options) =>
ofetch(url, {
...options,
headers: {
host: 'nhentai.net',
@ -77,7 +77,7 @@ const gotByIp = (url, ...options) =>
});
const getSimple = async (url) => {
const { data } = await gotByIp(url);
const data = await oFetch(url);
const $ = load(data);
return $('.gallery a.cover')
@ -113,17 +113,17 @@ const parseSimpleDetail = ($ele) => {
const getTorrent = async (simple, cookie) => {
const { link } = simple;
const response = await gotByIp(link + 'download', { followRedirect: false, responseType: 'buffer', headers: { Cookie: cookie } });
const response = await oFetch(link + 'download', { followRedirect: false, responseType: 'buffer', headers: { Cookie: cookie } });
return {
...simple,
enclosure_url: response.data,
enclosure_url: response,
enclosure_type: 'application/x-bittorrent',
};
};
const getDetail = async (simple) => {
const { link } = simple;
const { data } = await gotByIp(link);
const data = await oFetch(link);
const $ = load(data);
const galleryImgs = $('.gallerythumb img')