mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-08-29 01:53:47 +08:00
fix(route): copymanga (#11670)
This commit is contained in:
@@ -71,7 +71,6 @@
|
||||
'ishuhui.com': { _name: '鼠绘漫画', www: [{ title: '鼠绘漫画', docs: 'https://docs.rsshub.app/anime.html#shu-hui-man-hua', source: '/comics/anime/:id', target: '/shuhui/comics/:id' }] },
|
||||
'www.chicagotribune.com': { _name: 'Chicago Tribune', www: [{ title: 'Chicago Tribune', docs: 'https://docs.rsshub.app/traditional_media.html#chicago-tribune', source: '/' }] },
|
||||
'haimaoba.com': { _name: '海猫吧', www: [{ title: '漫画更新', docs: 'https://docs.rsshub.app/anime.html#hai-mao-ba', source: '/catalog/:id', target: '/haimaoba/:id' }] },
|
||||
'copymanga.com': { _name: '拷贝漫画', www: [{ title: '漫画更新', docs: 'https://docs.rsshub.app/anime.html#kao-bei-man-hua', source: '/comic/:id/', target: '/manhuagui/comic/:id/5' }] },
|
||||
'pgyer.com': { _name: '蒲公英应用分发', www: [{ title: 'app更新', docs: 'https://docs.rsshub.app/program-update.html#pu-gong-ying-ying-yong-fen-fa', source: '/:app', target: '/pgyer/:app' }] },
|
||||
'wineyun.com': { _name: '酒云网', www: [{ title: '最新商品', docs: 'https://docs.rsshub.app/other.html#jiu-yun-wang', source: ['/:category'], target: '/wineyun/:category' }] },
|
||||
'epicgames.com': { _name: 'Epic Games', www: [{ title: '每周免费游戏', docs: 'https://docs.rsshub.app/game.html#epicgames-freegame', source: '/store/zh-CN/free-games', target: '/epicgames/freegames' }] },
|
||||
|
||||
+1
-1
@@ -695,7 +695,7 @@ Sources
|
||||
|
||||
### 漫画更新
|
||||
|
||||
<Route author="btdwv marvolo666 yan12125" path="/copymanga/comic/:id/:chapterCnt?" example="/copymanga/comic/zaiyishijiemigongkaihougong/5" :paramsDesc="['漫画ID','返回章节的数量,默认为0,返回所有章节']" radar="1" rssbud="1"/>
|
||||
<Route author="btdwv marvolo666 yan12125" path="/copymanga/comic/:id/:chapterCnt?" example="/copymanga/comic/dianjuren/5" :paramsDesc="['漫画ID', '返回章节的数量,默认为0,返回所有章节']" radar="1" rssbud="1"/>
|
||||
|
||||
## 漫画 DB
|
||||
|
||||
|
||||
+2
-2
@@ -1001,10 +1001,10 @@ router.get('/tencentvideo/playlist/:id', lazyloadRouteHandler('./routes/tencent/
|
||||
// router.get('/twmanhuagui/comic/:id/:chapterCnt?', lazyloadRouteHandler('./routes/twmanhuagui/comic'));
|
||||
|
||||
// 拷贝漫画
|
||||
router.get('/copymanga/comic/:id/:chapterCnt?', lazyloadRouteHandler('./routes/copymanga/comic'));
|
||||
// router.get('/copymanga/comic/:id/:chapterCnt?', lazyloadRouteHandler('./routes/copymanga/comic'));
|
||||
|
||||
// 拷贝漫画
|
||||
router.get('/copymanga/comic/:id', lazyloadRouteHandler('./routes/copymanga/comic'));
|
||||
// router.get('/copymanga/comic/:id', lazyloadRouteHandler('./routes/copymanga/comic'));
|
||||
|
||||
// 動漫狂
|
||||
router.get('/cartoonmad/comic/:id', lazyloadRouteHandler('./routes/cartoonmad/comic'));
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
|
||||
// 直接调用拷贝漫画的接口
|
||||
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 = `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(),
|
||||
});
|
||||
|
||||
let itemsLen = chapterArray.length;
|
||||
|
||||
if (chapterCnt > 0) {
|
||||
itemsLen = chapterCnt;
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
title: `拷贝漫画 - ${bookTitle}`,
|
||||
link: `https://copymanga.com/comic/${id}`,
|
||||
description: bookIntro,
|
||||
item: chapterArray.map(genResult).slice(0, itemsLen),
|
||||
};
|
||||
};
|
||||
@@ -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)))),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/comic/:id/:chapterCnt?': ['btdwv', 'marvolo666', 'yan12125'],
|
||||
};
|
||||
@@ -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,
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/comic/:id/:chapterCnt?', require('./comic'));
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
<h1>{{ size }}p</h1><br>
|
||||
{{ each contents img }}
|
||||
<img src="{{ img.url }}" alt="{{ img.page }}">
|
||||
{{ /each }}
|
||||
Reference in New Issue
Block a user