add loveheaven

This commit is contained in:
hoilc
2020-02-29 14:46:41 +08:00
parent d28d959776
commit 408b53a4fa
5 changed files with 61 additions and 0 deletions
+6
View File
@@ -61,6 +61,12 @@ For example:
</RouteEn>
## LoveHeaven
### Manga Updates
<RouteEn author="hoilc" example="/loveheaven/update/kimetsu-no-yaiba" path="/loveheaven/update/:slug" :paramsDesc="['Manga slug, can be found in URL, including neither `manga-` nor `.html`']" />
## nHentai
### Filter
+6
View File
@@ -79,6 +79,12 @@ pageClass: routes
</Route>
## LoveHeaven
### 漫画更新
<Route author="hoilc" example="/loveheaven/update/kimetsu-no-yaiba" path="/loveheaven/update/:slug" :paramsDesc="['漫画 slug,可在漫画页面URL中找到,不包括开头的`manga-`,也不包括末尾的`.html`']" />
## nHentai
### 分类筛选
+3
View File
@@ -2312,4 +2312,7 @@ router.get('/wolley/host/:host', require('./routes/wolley/host'));
// 西安交大
router.get('/xjtu/dean/:subpath+', require('./routes/universities/xjtu/dean'));
// LoveHeaven
router.get('/loveheaven/update/:slug', require('./routes/loveheaven/update'));
module.exports = router;
+45
View File
@@ -0,0 +1,45 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const chrono = require('chrono-node');
const base = 'https://loveheaven.net/';
module.exports = async (ctx) => {
const slug = ctx.params.slug;
const url = `https://loveheaven.net/manga-${slug.replace(/^manga-/, '').replace(/\.html$/, '')}.html`;
const response = await got.get(url);
const $ = cheerio.load(response.data);
const manga_name = $('.manga-info > h1').text();
const manga_other_names = $('.manga-info > li:nth-child(3)').text();
const manga_author = $('a.btn-info')
.map(function() {
return $(this).text();
})
.get()
.join(', ');
const manga_cover = $('img.thumbnail').attr('src');
const list = $('.tab-text .table > tbody > tr').get();
ctx.state.data = {
title: `${manga_name} - LoveHeaven`,
description: manga_other_names,
link: url,
image: manga_cover,
item: list.slice(0, 20).map((item) => {
item = $(item);
const entry = item.find('a');
const humanized_date = item.find('time').text();
return {
title: entry.text(),
author: manga_author,
description: `<img src="${manga_cover}" style="max-width: 100%;">`,
link: base + entry.attr('href'),
pubDate: humanized_date ? chrono.parseDate(humanized_date) : new Date(),
};
}),
};
};
+1
View File
@@ -65,6 +65,7 @@
"aes-js": "3.1.2",
"art-template": "4.13.2",
"cheerio": "1.0.0-rc.3",
"chrono-node": "1.4.3",
"cloudscraper": "4.6.0",
"co-redis": "2.1.1",
"currency-symbol-map": "4.0.4",