forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nhentai: added simple mode (DIYgod#1191)
* nhentai: added simple mode * nhentai: detail limit & deleted console.log
- Loading branch information
Showing
5 changed files
with
46 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
const { getList, getDetailWithCache } = require('./util'); | ||
const { getSimple, getDetails } = require('./util'); | ||
|
||
const supportedKeys = ['parody', 'character', 'tag', 'artist', 'group', 'language', 'category']; | ||
|
||
module.exports = async (ctx) => { | ||
const { keyword, key } = ctx.params; | ||
const { keyword, key, mode } = ctx.params; | ||
const isSimple = mode !== 'detail'; | ||
|
||
if (supportedKeys.indexOf(key) === -1) { | ||
ctx.state.data = { | ||
title: 'nHentai - unsupported', | ||
}; | ||
return; | ||
} | ||
|
||
const list = await getList(`https://nhentai.net/${key}/${keyword.toLowerCase().replace(' ', '-')}`); | ||
const details = await Promise.all(list.map(getDetailWithCache.bind(null, ctx.cache))); | ||
const simples = await getSimple(`https://nhentai.net/${key}/${keyword.toLowerCase().replace(' ', '-')}`); | ||
|
||
ctx.state.data = { | ||
title: `nHentai - ${key} - ${keyword}`, | ||
link: 'https://nhentai.net', | ||
description: 'hentai', | ||
item: details, | ||
item: isSimple ? simples : await getDetails(ctx.cache, simples), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
const { getList, getDetailWithCache } = require('./util'); | ||
const { getSimple, getDetails } = require('./util'); | ||
|
||
module.exports = async (ctx) => { | ||
const { keyword } = ctx.params; | ||
const list = await getList(`https://nhentai.net/search/?q=${keyword}`); | ||
const details = await Promise.all(list.map(getDetailWithCache.bind(null, ctx.cache))); | ||
const { keyword, mode } = ctx.params; | ||
const isSimple = mode !== 'detail'; | ||
|
||
const simples = await getSimple(`https://nhentai.net/search/?q=${keyword}`); | ||
|
||
ctx.state.data = { | ||
title: `nHentai - search - ${keyword}`, | ||
link: 'https://nhentai.net', | ||
description: 'hentai', | ||
item: details, | ||
item: isSimple ? simples : await getDetails(ctx.cache, simples), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters