feat(route): add sfacg (#14579)
* feat(route): add sfacg * refactor code * feat: add radar.js * update description * add feed desc & img * update radar.js * update http url replacement * fix: radar * fix: maintainer ---------
This commit is contained in:
parent
b735b645d8
commit
09cf6dbdd2
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/novel/chapter/:id': ['keocheung'],
|
||||
};
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
const limit = Number.parseInt(ctx.query.limit) || 20;
|
||||
|
||||
const baseUrl = 'https://book.sfacg.com';
|
||||
|
||||
const { data: response } = await got(`${baseUrl}/Novel/${id}/MainIndex/`);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const list = $('div.catalog-list ul li a')
|
||||
.slice(-limit)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.attr('title'),
|
||||
link: `${baseUrl}${item.attr('href')}`,
|
||||
};
|
||||
});
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
item.description = $('div.article-content').html();
|
||||
|
||||
const rawDate = $('div.article-desc span').eq(1).text();
|
||||
item.pubDate = timezone(parseDate(rawDate.replace('更新时间:', '')), +8);
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
const { data: intro } = await got(`${baseUrl}/Novel/${id}/`);
|
||||
const $i = cheerio.load(intro);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `SF轻小说 ${$('h1.story-title').text()}`,
|
||||
link: `${baseUrl}/Novel/${id}`,
|
||||
description: $i('p.introduce').text(),
|
||||
image: $i('div.summary-pic img').attr('src').replace('http://', 'https://'),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'sfacg.com': {
|
||||
_name: 'SF 轻小说',
|
||||
book: [
|
||||
{
|
||||
title: '章节',
|
||||
docs: 'https://docs.rsshub.app/routes/reading#sf-qing-xiao-shuo',
|
||||
source: ['/Novel/:id/*'],
|
||||
target: '/sfacg/novel/chapter/:id',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/novel/chapter/:id', require('./novel-chapter'));
|
||||
};
|
||||
|
|
@ -66,6 +66,12 @@
|
|||
|
||||
<Route author="StevenRCE0" example="/penguin-random-house/articles" path="/penguin-random-house/articles" />
|
||||
|
||||
## SF 轻小说 {#sf-qing-xiao-shuo}
|
||||
|
||||
### 章节 {#sf-qing-xiao-shuo-zhang-jie}
|
||||
|
||||
<Route author="keocheung" example="/sfacg/novel/chapter/672431" path="/sfacg/novel/chapter/:id" paramsDesc={['小说 id, 可在对应小说页 URL 中找到']} radar="1" />
|
||||
|
||||
## SoBooks {#sobooks}
|
||||
|
||||
### 首页 {#sobooks-shou-ye}
|
||||
|
|
|
|||
Loading…
Reference in New Issue