Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(route): nhentai #12170

Merged
merged 1 commit into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(route): nhentai
  • Loading branch information
TonyRL committed Mar 24, 2023
commit 865cdced76c5c8a7c790e599c581a4ad41b2bda8
10 changes: 10 additions & 0 deletions docs/anime.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,16 @@ Sources

</Route>

## nhentai

### 分类筛选

<Route author="MegrezZhu hoilc" example="/nhentai/language/chinese" path="/nhentai/:key/:keyword/:mode?" :paramsDesc="['筛选条件,可选:parody, character, tag, artist, group, language, category','筛选值', '模式,`simple` 为仅封面,`detail` 会包括本子每一页,但对服务器负载大,`torrent` 会包括磁力链接,需要登录,参见 [部分 RSS 模块配置](/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi)。默认为 `simple`']" anticrawler="1" supportBT="1" />

### 高级搜索

<Route author="MegrezZhu hoilc" example='/nhentai/search/language%3Ajapanese+-scat+-yaoi+-guro+-"mosaic+censorship"' path="/nhentai/search/:keyword/:mode?" :paramsDesc="['用于搜索的关键词。可在原网站搜索后复制 `q=` 后面的内容,也可直接输入。用法详见 [官网](https://nhentai.net/info/)', '模式,`simple` 为仅封面,`detail` 会包括本子每一页,但对服务器负载大,`torrent` 会包括磁力链接,需要登录,参见 [部分 RSS 模块配置](/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi)。默认为 `simple`']" anticrawler="1" supportBT="1" />

## QooApp

### 遊戲庫 - 評論
Expand Down
10 changes: 10 additions & 0 deletions docs/en/anime.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ The RSS routing has not been rigorously tested and the information provided cann

<RouteEn author="vzz64" example="/mangadex/58be6aa6-06cb-4ca5-bd20-f1392ce451fb/en" path="/:id/:lang?" :paramsDesc="['manga ID', 'language code']" radar="1" />

## nhentai

### Filter

<RouteEn author="MegrezZhu hoilc" example="/nhentai/language/chinese" path="/nhentai/:key/:keyword/:mode?" :paramsDesc="['Filter term, can be: `parody`, `character`, `tag`, `artist`, `group`, `language` or `category`','Filter value', 'mode, `simple` to only show cover, `detail` to show all pages, `torrent` to include Magnet URI, need login, refer to [Route-specific Configurations](/en/install/#configuration-route-specific-configurations), default to `simple`']" anticrawler="1" supportBT="1" radar="1"/>

### Advanced Search

<RouteEn author="MegrezZhu hoilc" example='/nhentai/search/language%3Ajapanese+-scat+-yaoi+-guro+-"mosaic+censorship"' path="/nhentai/search/:keyword/:mode?" :paramsDesc="['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, `simple` to only show cover, `detail` to show all pages, `torrent` to include Magnet URI, need login, refer to [Route-specific Configurations](/en/install/#configuration-route-specific-configurations), default to `simple`']" anticrawler="1" supportBT="1" radar="1"/>

## QooApp

### Game Store - Review
Expand Down
10 changes: 0 additions & 10 deletions docs/en/picture.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,6 @@ For example:

<RouteEn author="LogicJake OrangeEd1t TonyRL" example="/natgeo/dailyphoto" path="/natgeo/dailyphoto"/>

## nHentai

### Filter

<RouteEn author="MegrezZhu hoilc" example="/nhentai/language/chinese" path="/nhentai/:key/:keyword/:mode?" :paramsDesc="['Filter term, can be: parody, character, tag, artist, group, language, category','Filter value', 'mode, `simple` to only cover,`detail` to all content, `torrent` to include Magnet URI, need login, refer to [Route-specific Configurations](/en/install/#route-specific-configurations), default to `simple`']" anticrawler="1" supportBT="1" />

### Advanced Search

<RouteEn author="MegrezZhu hoilc" example="/nhentai/search/language%3Ajapanese+-scat+-yaoi+-guro+-%22mosaic+censorship%22" path="/nhentai/search/:keyword/:mode?" :paramsDesc="['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, `simple` to only cover,`detail` to all content, `torrent` to include Magnet URI, need login, refer to [Route-specific Configurations](/en/install/#route-specific-configurations), default to `simple`']" anticrawler="1" supportBT="1"/>

## Pixabay

### Search
Expand Down
10 changes: 0 additions & 10 deletions docs/picture.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,16 +374,6 @@ R18 显示

</Route>

## nHentai

### 分类筛选

<Route author="MegrezZhu hoilc" example="/nhentai/language/chinese" path="/nhentai/:key/:keyword/:mode?" :paramsDesc="['筛选条件,可选: parody, character, tag, artist, group, language, category','筛选值', '模式,`simple`为仅封面,`detail`会包括本子每一页,但对服务器负载大,`torrent`会包括磁力链接,需要登录,参见[部分 RSS 模块配置](/install/#bu-fen-rss-mo-kuai-pei-zhi)。默认为`simple`']" anticrawler="1" supportBT="1" />

### 高级搜索

<Route author="MegrezZhu hoilc" example="/nhentai/search/language%3Ajapanese+-scat+-yaoi+-guro+-%22mosaic+censorship%22" path="/nhentai/search/:keyword/:mode?" :paramsDesc="['用于搜索的关键词。可在原网站搜索后复制 q= 后面的内容,也可直接输入。用法详见[官网](https://nhentai.net/info/)', '模式,`simple`为仅封面,`detail`会包括本子每一页,但对服务器负载大,`torrent`会包括磁力链接,需要登录,参见[部分 RSS 模块配置](/install/#bu-fen-rss-mo-kuai-pei-zhi)。默认为`simple`']" anticrawler="1" supportBT="1" />

## Porn Image XXX

### 最新图片
Expand Down
4 changes: 2 additions & 2 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,8 @@ router.get('/chouti/:subject?', lazyloadRouteHandler('./routes/chouti'));
router.get('/westore/new', lazyloadRouteHandler('./routes/westore/new'));

// nHentai
router.get('/nhentai/search/:keyword/:mode?', lazyloadRouteHandler('./routes/nhentai/search'));
router.get('/nhentai/:key/:keyword/:mode?', lazyloadRouteHandler('./routes/nhentai/other'));
// router.get('/nhentai/search/:keyword/:mode?', lazyloadRouteHandler('./routes/nhentai/search'));
// router.get('/nhentai/:key/:keyword/:mode?', lazyloadRouteHandler('./routes/nhentai/other'));

// 龙腾网
router.get('/ltaaa/:category?', lazyloadRouteHandler('./routes/ltaaa/index'));
Expand Down
25 changes: 0 additions & 25 deletions lib/routes/nhentai/other.js

This file was deleted.

16 changes: 0 additions & 16 deletions lib/routes/nhentai/search.js

This file was deleted.

133 changes: 0 additions & 133 deletions lib/routes/nhentai/util.js

This file was deleted.

4 changes: 4 additions & 0 deletions lib/v2/nhentai/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
'/search/:keyword/:mode?': ['MegrezZhu', 'hoilc'],
'/:key/:keyword/:mode?': ['MegrezZhu', 'hoilc'],
};
30 changes: 30 additions & 0 deletions lib/v2/nhentai/other.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const { getSimple, getDetails, getTorrents } = require('./util');

const supportedKeys = ['parody', 'character', 'tag', 'artist', 'group', 'language', 'category'];

module.exports = async (ctx) => {
const { key, keyword, mode } = ctx.params;

if (!supportedKeys.includes(key)) {
throw Error('Unsupported key');
}

const url = `https://nhentai.net/${key}/${keyword.toLowerCase().replace(' ', '-')}/`;

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 - ${key} - ${keyword}`,
link: url,
description: 'hentai',
item: items,
};
};
19 changes: 19 additions & 0 deletions lib/v2/nhentai/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
'nhentai.net': {
_name: 'nhentai',
'.': [
{
title: '分类筛选',
docs: 'https://docs.rsshub.app/anime.html#nhentai',
source: ['/:key/:keyword'],
target: '/nhentai/:key/:keyword',
},
{
title: '高级搜索',
docs: 'https://docs.rsshub.app/anime.html#nhentai',
source: ['/search'],
target: (_, url) => `/nhentai/search/${new URL(url).searchParams.get('q')}`,
},
],
},
};
4 changes: 4 additions & 0 deletions lib/v2/nhentai/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = (router) => {
router.get('/search/:keyword/:mode?', require('./search'));
router.get('/:key/:keyword/:mode?', require('./other'));
};
23 changes: 23 additions & 0 deletions lib/v2/nhentai/search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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,
};
};
4 changes: 4 additions & 0 deletions lib/v2/nhentai/templates/desc.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<h1>{{ length }} pages</h1><br>
{{ each images i }}
<img src="{{ i }}"><br>
{{ /each }}
Loading