diff --git a/docs/en/reading.md b/docs/en/reading.md index 785018410..dfcb5c610 100644 --- a/docs/en/reading.md +++ b/docs/en/reading.md @@ -12,6 +12,10 @@ pageClass: routes ## Literotica +### New Stories + + + ### Category diff --git a/docs/reading.md b/docs/reading.md index eff178701..673b00a60 100644 --- a/docs/reading.md +++ b/docs/reading.md @@ -26,6 +26,10 @@ pageClass: routes ### New Stories + + +### Category + ## Mobilism diff --git a/lib/v2/literotica/maintainer.js b/lib/v2/literotica/maintainer.js index fc7773855..08da81754 100644 --- a/lib/v2/literotica/maintainer.js +++ b/lib/v2/literotica/maintainer.js @@ -1,3 +1,4 @@ module.exports = { + '/new': ['nczitzk'], '/category/:category': ['nczitzk'], }; diff --git a/lib/v2/literotica/new.js b/lib/v2/literotica/new.js new file mode 100644 index 000000000..1b04c46de --- /dev/null +++ b/lib/v2/literotica/new.js @@ -0,0 +1,59 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const rootUrl = 'https://www.literotica.com'; + const currentUrl = `${rootUrl}/stories/new_submissions.php`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('.b-46t') + .map((_, item) => { + item = $(item); + + const a = item.find('.p-48y'); + + return { + title: a.text(), + link: a.attr('href'), + category: item.nextAll().eq(3).text().replace(/\(|\)/g, '').trim(), + pubDate: parseDate(item.nextAll().eq(4).text().trim(), 'MM/DD/YY'), + author: item + .nextAll() + .eq(2) + .text() + .replace(/Submitted by/, '') + .trim(), + }; + }) + .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/radar.js b/lib/v2/literotica/radar.js index 597075ffa..a27faa757 100644 --- a/lib/v2/literotica/radar.js +++ b/lib/v2/literotica/radar.js @@ -2,6 +2,12 @@ module.exports = { 'literotica.com': { _name: 'Literotica', '.': [ + { + title: 'New Stories', + docs: 'https://docs.rsshub.app/reading.html#literotica-new-stories', + source: ['/'], + target: '/literotica/new', + }, { title: 'Category', docs: 'https://docs.rsshub.app/reading.html#literotica-category', diff --git a/lib/v2/literotica/router.js b/lib/v2/literotica/router.js index babffa269..d73ee9e22 100644 --- a/lib/v2/literotica/router.js +++ b/lib/v2/literotica/router.js @@ -1,3 +1,4 @@ module.exports = function (router) { + router.get('/new', require('./new')); router.get('/category/:category', require('./category')); };