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.
Merge pull request #742 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
11 changed files
with
143 additions
and
80 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
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
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
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
This file was deleted.
Oops, something went wrong.
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,110 @@ | ||
const cheerio = require('cheerio'); | ||
const got = require('@/utils/got'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
const { art } = require('@/utils/render'); | ||
const path = require('path'); | ||
|
||
const host = 'copymanga.site'; | ||
const baseUrl = `https://${host}`; | ||
const apiBaseUrl = `https://api.${host}`; | ||
|
||
// 直接调用拷贝漫画的接口 | ||
module.exports = async (ctx) => { | ||
const { id } = ctx.params; | ||
// 用于控制返回的章节数量 | ||
const chapterCnt = Number(ctx.params.chapterCnt || 0); | ||
// 获取漫画列表 | ||
let bHasNextPage = false; | ||
const iReqLimit = (ctx.queries && ctx.queries.limit) || 100; | ||
let iReqOffSet = 0; | ||
const strBaseUrl = `${apiBaseUrl}/api/v3/comic/${id}/group/default/chapters`; | ||
let chapterArray = []; | ||
|
||
do { | ||
bHasNextPage = false; | ||
// eslint-disable-next-line no-await-in-loop | ||
const { data } = await got(strBaseUrl, { | ||
headers: { | ||
platform: 1, | ||
}, | ||
searchParams: { | ||
limit: iReqLimit, | ||
offset: iReqOffSet === 0 ? undefined : iReqOffSet, | ||
}, | ||
}); | ||
const { code, results } = data; | ||
|
||
if (code !== 200) { | ||
break; | ||
} | ||
|
||
if (results.limit + results.offset < results.total) { | ||
bHasNextPage = true; | ||
} | ||
iReqOffSet += iReqLimit; | ||
|
||
chapterArray = [...chapterArray, ...results.list]; | ||
} while (bHasNextPage); | ||
|
||
chapterArray = chapterArray | ||
.map(({ comic_path_word, uuid, name, size, datetime_created /* , index*/ }) => ({ | ||
link: `${baseUrl}/comic/${comic_path_word}/chapter/${uuid}`, | ||
uuid, | ||
title: name, | ||
size, | ||
pubDate: datetime_created, | ||
// index, | ||
})) | ||
.reverse(); | ||
|
||
// 获取漫画标题、介绍 | ||
const { bookTitle, bookIntro } = await ctx.cache.tryGet(`${baseUrl}/comic/${id}`, async () => { | ||
const { data } = await got(`${baseUrl}/comic/${id}`); | ||
const $ = cheerio.load(data); | ||
return { | ||
bookTitle: $('.comicParticulars-title-right > ul > li > h6').text(), | ||
bookIntro: $('.intro').text(), | ||
}; | ||
}); | ||
|
||
const genResult = async (chapter) => { | ||
const { | ||
data: { results }, | ||
} = await got(`${apiBaseUrl}/api/v3/comic/${id}/chapter2/${chapter.uuid}`, { | ||
headers: { | ||
webp: 1, | ||
}, | ||
}); | ||
|
||
const pageNumbers = Object.values(results.chapter.words); | ||
const contents = results.chapter.contents | ||
.map((content, index) => ({ | ||
page: pageNumbers[index], | ||
url: content.url, | ||
})) | ||
.sort((a, b) => a.page - b.page); | ||
|
||
return { | ||
link: chapter.link, | ||
title: chapter.title, | ||
description: art(path.join(__dirname, './templates/comic.art'), { | ||
size: chapter.size, | ||
contents, | ||
}), | ||
pubDate: parseDate(chapter.pubDate, 'YYYY-MM-DD'), | ||
}; | ||
}; | ||
|
||
let itemsLen = chapterArray.length; | ||
|
||
if (chapterCnt > 0) { | ||
itemsLen = chapterCnt; | ||
} | ||
|
||
ctx.state.data = { | ||
title: `拷贝漫画 - ${bookTitle}`, | ||
link: `${baseUrl}/comic/${id}`, | ||
description: bookIntro, | ||
item: await Promise.all(chapterArray.slice(0, itemsLen).map((chapter) => ctx.cache.tryGet(chapter.link, () => genResult(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/comic/:id/:chapterCnt?': ['btdwv', 'marvolo666', 'yan12125'], | ||
}; |
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,19 @@ | ||
const copymanga = { | ||
_name: '拷贝漫画', | ||
'.': [ | ||
{ | ||
title: '漫画更新', | ||
docs: 'https://docs.rsshub.app/anime.html#kao-bei-man-hua', | ||
source: '/comic/:id', | ||
target: '/copymanga/comic/:id/5', | ||
}, | ||
], | ||
}; | ||
|
||
module.exports = { | ||
'copymanga.com': copymanga, | ||
'copymanga.info': copymanga, | ||
'copymanga.net': copymanga, | ||
'copymanga.org': copymanga, | ||
'copymanga.site': copymanga, | ||
}; |
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('/comic/:id/:chapterCnt?', require('./comic')); | ||
}; |
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,4 @@ | ||
<h1>{{ size }}p</h1><br> | ||
{{ each contents img }} | ||
<img src="{{ img.url }}" alt="{{ img.page }}"> | ||
{{ /each }} |
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
0f18eda
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
rsshub-master – ./
rsshub-master.vercel.app
rsshub-master-git-master-auto-bot-ty.vercel.app
rsshub-master-auto-bot-ty.vercel.app