diff --git a/docs/en/multimedia.md b/docs/en/multimedia.md index 97a2ff230a..27c42edd81 100644 --- a/docs/en/multimedia.md +++ b/docs/en/multimedia.md @@ -122,6 +122,18 @@ Refer to [Pornhub F.A.Qs](https://help.pornhub.com/hc/en-us/articles/36004432703 - `cn` (Chinese), for Pornhub in China ; - `jp` (Japanese), for Pornhub in Japan etc. +## s-hentai + +### Category + + + +| Doujin | HCG | Games・Animes | Voices・ASMR | Ready to Download | +| ------ | --- | ------------- | ------------ | ----------------- | +| 1 | 2 | 3 | 4 | ready-to-download | + + + ## Sankaku Complex ### Post diff --git a/docs/multimedia.md b/docs/multimedia.md index 1196a890a7..28cc5b1bce 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -628,6 +628,18 @@ pageClass: routes +## s-hentai + +### Category + + + +| Doujin | HCG | Games・Animes | Voices・ASMR | Ready to Download | +| ------ | --- | ------------- | ------------ | ----------------- | +| 1 | 2 | 3 | 4 | ready-to-download | + + + ## Sankaku Complex ### Post diff --git a/lib/router.js b/lib/router.js index 17662a7885..62ab3c0799 100644 --- a/lib/router.js +++ b/lib/router.js @@ -4246,4 +4246,7 @@ router.get('/biodiscover/:channel?', lazyloadRouteHandler('./routes/biodiscover' // 香港經濟日報 router.get('/hket/:category?', lazyloadRouteHandler('./routes/hket/index')); +// s-hentai +router.get('/s-hentai/:id?', lazyloadRouteHandler('./routes/s-hentai')); + module.exports = router; diff --git a/lib/routes/s-hentai/index.js b/lib/routes/s-hentai/index.js new file mode 100644 index 0000000000..8aaaa34e29 --- /dev/null +++ b/lib/routes/s-hentai/index.js @@ -0,0 +1,64 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const id = ctx.params.id || 'ready-to-download'; + + const rootUrl = 'https://s-hentai.org'; + const currentUrl = `${rootUrl}/${id === 'ready-to-download' ? id : `menu/${id}`}`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('.block-product') + .slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 20) + .map((_, item) => { + item = $(item); + + const a = item.find('.name-product a'); + + return { + title: a.text(), + link: a.attr('href'), + pubDate: parseDate(item.find('.post-date').text().trim().split(' ')[0], 'YYYY年MM月DD日'), + }; + }) + .get(); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + const images = content('#sync1'); + const description = content('#description-deital'); + + content('.single-support').remove(); + + item.enclosure_url = content('.file-download-comment a').eq(0).attr('href'); + item.enclosure_type = 'application/x-bittorrent'; + + item.description = (images ? images.html() : '') + content('.detial-short').html() + (description ? description.html() : ''); + item.category = detailResponse.data.match(/(.*)<\/a>/g).map((category) => category.match(/>(.*)