diff --git a/docs/en/reading.md b/docs/en/reading.md index 930f3a23566a36..7850184100ccc6 100644 --- a/docs/en/reading.md +++ b/docs/en/reading.md @@ -9,3 +9,9 @@ pageClass: routes ### Poems + +## Literotica + +### Category + + diff --git a/docs/reading.md b/docs/reading.md index 663b32ec3e813b..eff17870127670 100644 --- a/docs/reading.md +++ b/docs/reading.md @@ -22,6 +22,12 @@ pageClass: routes +## Literotica + +### New Stories + + + ## Mobilism ### eBook Releases diff --git a/lib/v2/literotica/category.js b/lib/v2/literotica/category.js new file mode 100644 index 00000000000000..839ffaa62b6384 --- /dev/null +++ b/lib/v2/literotica/category.js @@ -0,0 +1,55 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const category = ctx.params.category; + + const rootUrl = 'https://www.literotica.com'; + const currentUrl = `${rootUrl}/c/${category}`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('.b-slb-item') + .map((_, item) => { + item = $(item); + + const a = item.find('h3 a'); + + return { + title: a.text(), + link: a.attr('href'), + author: item.find('.b-user-info-name').text(), + pubDate: parseDate(item.find('.b-slib-date').text(), 'MM/DD/YY'), + }; + }) + .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); + + item.description = content('.aa_ht').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/literotica/maintainer.js b/lib/v2/literotica/maintainer.js new file mode 100644 index 00000000000000..fc777385564cea --- /dev/null +++ b/lib/v2/literotica/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/category/:category': ['nczitzk'], +}; diff --git a/lib/v2/literotica/radar.js b/lib/v2/literotica/radar.js new file mode 100644 index 00000000000000..597075ffa2f890 --- /dev/null +++ b/lib/v2/literotica/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'literotica.com': { + _name: 'Literotica', + '.': [ + { + title: 'Category', + docs: 'https://docs.rsshub.app/reading.html#literotica-category', + source: ['/c/:category', '/'], + target: '/literotica/category/:category', + }, + ], + }, +}; diff --git a/lib/v2/literotica/router.js b/lib/v2/literotica/router.js new file mode 100644 index 00000000000000..babffa26923bfa --- /dev/null +++ b/lib/v2/literotica/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/category/:category', require('./category')); +};