forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add 刺猬猫 * fix getting chapter content * add docs & radar; fix image * update default limit * do not fetch chapter content if chapter is locked
- Loading branch information
Showing
5 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
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) || 10; | ||
|
||
const baseUrl = 'https://wap.ciweimao.com'; | ||
const chapterUrl = 'https://mip.ciweimao.com'; | ||
|
||
const { data: response } = await got(`${baseUrl}/book/${id}`); | ||
const $ = cheerio.load(response); | ||
|
||
const firstChapterUrl = $('ul.catalogue-list li a').attr('href'); | ||
const firstChapterId = firstChapterUrl.substring(firstChapterUrl.lastIndexOf('/') + 1); | ||
|
||
const { data: chapters } = await got(`${chapterUrl}/chapter/${id}/${firstChapterId}`); | ||
const $c = cheerio.load(chapters); | ||
|
||
const list = $c('ul.book-chapter li a') | ||
.slice(-limit) | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
return { | ||
chapterLocked: item.find('h3 i.icon-lock').length > 0, | ||
title: item.find('h3').text(), | ||
pubDate: timezone(parseDate(item.find('p').text().replace('发布于 ', '')), +8), | ||
link: item.attr('href'), | ||
}; | ||
}); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
if (item.chapterLocked) { | ||
return item; | ||
} | ||
const { data: response } = await got(item.link); | ||
const $ = cheerio.load(response); | ||
|
||
const content = $('div.read-bd'); | ||
content.find('span, a').remove(); | ||
content.find('p').removeAttr('class'); | ||
item.description = content.html(); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: `刺猬猫 ${$('.book-name').text()}`, | ||
link: `${baseUrl}/book/${id}`, | ||
description: $('.book-desc div p').text(), | ||
image: $('meta[name=image]').attr('content'), | ||
item: items, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/chapter/:id': ['keocheung'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
'ciweimao.com': { | ||
_name: '刺猬猫', | ||
wap: [ | ||
{ | ||
title: '章节', | ||
docs: 'https://docs.rsshub.app/routes/reading#ci-wei-mao', | ||
source: ['/book/:id'], | ||
target: '/ciweimao/chapter/:id', | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = (router) => { | ||
router.get('/chapter/:id', require('./chapter')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters