mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-15 01:30:33 +08:00
feat(route):add 拷贝漫画 (#7896)
Co-authored-by: SettingDust <settingdust@gmail.com> Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
@@ -318,6 +318,12 @@ pageClass: routes
|
|||||||
|
|
||||||
<Route author="btdwv" path="/twmanhuagui/comic/:id" example="/twmanhuagui/comic/13317" :paramsDesc="['漫画ID']" radar="1" rssbud="1"/>
|
<Route author="btdwv" path="/twmanhuagui/comic/:id" example="/twmanhuagui/comic/13317" :paramsDesc="['漫画ID']" radar="1" rssbud="1"/>
|
||||||
|
|
||||||
|
## 拷贝漫画
|
||||||
|
|
||||||
|
### 漫画更新
|
||||||
|
|
||||||
|
<Route author="btdwv" path="/copymanga/comic/:id" example="/copymanga/comic/zhandoupohuaixueyuandangerous" :paramsDesc="['漫画ID']" radar="1" rssbud="1"/>
|
||||||
|
|
||||||
## 漫画 DB
|
## 漫画 DB
|
||||||
|
|
||||||
### 漫画 DB
|
### 漫画 DB
|
||||||
|
|||||||
@@ -1137,6 +1137,9 @@ router.get('/manhuagui/comic/:id', lazyloadRouteHandler('./routes/manhuagui/comi
|
|||||||
router.get('/mhgui/comic/:id', lazyloadRouteHandler('./routes/mhgui/comic'));
|
router.get('/mhgui/comic/:id', lazyloadRouteHandler('./routes/mhgui/comic'));
|
||||||
router.get('/twmanhuagui/comic/:id', lazyloadRouteHandler('./routes/twmanhuagui/comic'));
|
router.get('/twmanhuagui/comic/:id', lazyloadRouteHandler('./routes/twmanhuagui/comic'));
|
||||||
|
|
||||||
|
// 拷贝漫画
|
||||||
|
router.get('/copymanga/comic/:id', lazyloadRouteHandler('./routes/copymanga/comic'));
|
||||||
|
|
||||||
// 動漫狂
|
// 動漫狂
|
||||||
router.get('/cartoonmad/comic/:id', lazyloadRouteHandler('./routes/cartoonmad/comic'));
|
router.get('/cartoonmad/comic/:id', lazyloadRouteHandler('./routes/cartoonmad/comic'));
|
||||||
// Vol
|
// Vol
|
||||||
|
|||||||
67
lib/routes/copymanga/comic.js
Normal file
67
lib/routes/copymanga/comic.js
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
const cheerio = require('cheerio');
|
||||||
|
const got = require('@/utils/got');
|
||||||
|
|
||||||
|
// 直接调用拷贝漫画的接口
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const { id } = ctx.params;
|
||||||
|
|
||||||
|
// 获取漫画列表
|
||||||
|
let bHasNextPage = false;
|
||||||
|
const iReqLimit = (ctx.queries && ctx.queries.limit) || 100;
|
||||||
|
let iReqOffSet = 0;
|
||||||
|
const strBaseUrl = `https://api.copymanga.com/api/v3/comic/${id}/group/default/chapters?`;
|
||||||
|
let chapterArray = [];
|
||||||
|
|
||||||
|
do {
|
||||||
|
bHasNextPage = false;
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
const { data } = await got.get(strBaseUrl + 'limit=' + iReqLimit + '&offset=' + iReqOffSet);
|
||||||
|
const { code, results } = data;
|
||||||
|
|
||||||
|
if (code !== 200) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (results.limit + results.offset < results.total) {
|
||||||
|
bHasNextPage = true;
|
||||||
|
}
|
||||||
|
iReqOffSet += iReqLimit;
|
||||||
|
|
||||||
|
chapterArray = chapterArray.concat(results.list);
|
||||||
|
} while (bHasNextPage);
|
||||||
|
|
||||||
|
chapterArray = chapterArray
|
||||||
|
.map(({ comic_path_word, uuid, name, size, datetime_created, index }) => ({
|
||||||
|
link: 'https://copymanga.com/comic/' + comic_path_word + '/chapter/' + uuid,
|
||||||
|
title: name,
|
||||||
|
num: size,
|
||||||
|
updateTime: datetime_created,
|
||||||
|
index,
|
||||||
|
}))
|
||||||
|
.reverse();
|
||||||
|
|
||||||
|
// 获取漫画标题、介绍
|
||||||
|
const { bookTitle, bookIntro } = await ctx.cache.tryGet(`https://copymanga.com/comic/${id}`, async () => {
|
||||||
|
const { data } = await got.get(`https://copymanga.com/comic/${id}`);
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
return {
|
||||||
|
bookTitle: $('.comicParticulars-title-right > ul > li > h6').text(),
|
||||||
|
bookIntro: $('.intro').text(),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const genResult = (chapter) => ({
|
||||||
|
link: chapter.link,
|
||||||
|
title: chapter.title,
|
||||||
|
description: `
|
||||||
|
<h1>${chapter.num}p</h1>
|
||||||
|
`.trim(),
|
||||||
|
});
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `拷贝漫画 - ${bookTitle}`,
|
||||||
|
link: `https://copymanga.com/comic/${id}`,
|
||||||
|
description: bookIntro,
|
||||||
|
item: chapterArray.map(genResult),
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user