feat(route): add Literotica Category (#8415)
This commit is contained in:
parent
3715f2b35e
commit
1dd850cb1c
|
|
@ -9,3 +9,9 @@ pageClass: routes
|
|||
### Poems
|
||||
|
||||
<RouteEn author="HenryQW" example="/allpoetry/newest" path="/allpoetry/:order?" :paramsDesc="['排序方式, `best` 或 `newest`, 缺省 `best`']"/>
|
||||
|
||||
## Literotica
|
||||
|
||||
### Category
|
||||
|
||||
<RouteEn author="nczitzk" example="/literotica/category/anal-sex-stories" path="/literotica/category/:category?" :paramsDesc="['Categor, can be found in URL']"/>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,12 @@ pageClass: routes
|
|||
|
||||
</Route>
|
||||
|
||||
## Literotica
|
||||
|
||||
### New Stories
|
||||
|
||||
<Route author="nczitzk" example="/literotica/category/anal-sex-stories" path="/literotica/category/:category?" :paramsDesc="['分类,可在对应分类页地址栏中找到']"/>
|
||||
|
||||
## Mobilism
|
||||
|
||||
### eBook Releases
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/category/:category': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -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',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/category/:category', require('./category'));
|
||||
};
|
||||
Loading…
Reference in New Issue