Skip to content

Commit

Permalink
Merge pull request #742 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Jan 23, 2023
2 parents aeb72c8 + 4c51a2b commit 0f18eda
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 80 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ jobs:
run: npm run jest:coverage
env:
REDIS_URL: redis://localhost:${{ job.services.redis.ports[6379] }}/
GH_ACTIONS: 1
- name: Upload coverage to Codecov
if: ${{ matrix.node-version == '18' }}
uses: codecov/codecov-action@v3
Expand Down
1 change: 0 additions & 1 deletion assets/radar-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }] },
Expand Down
2 changes: 1 addition & 1 deletion docs/anime.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
74 changes: 0 additions & 74 deletions lib/routes/copymanga/comic.js

This file was deleted.

110 changes: 110 additions & 0 deletions lib/v2/copymanga/comic.js
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)))),
};
};
3 changes: 3 additions & 0 deletions lib/v2/copymanga/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/comic/:id/:chapterCnt?': ['btdwv', 'marvolo666', 'yan12125'],
};
19 changes: 19 additions & 0 deletions lib/v2/copymanga/radar.js
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,
};
3 changes: 3 additions & 0 deletions lib/v2/copymanga/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/comic/:id/:chapterCnt?', require('./comic'));
};
4 changes: 4 additions & 0 deletions lib/v2/copymanga/templates/comic.art
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 }}
2 changes: 1 addition & 1 deletion test/utils/puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('puppeteer', () => {
browser = null;
}, 45000);

if (!process.env.GH_ACTIONS) {
if (!process.env.GITHUB_ACTIONS) {
it('puppeteer without stealth', async () => {
puppeteer = require('../../lib/utils/puppeteer');
browser = await puppeteer({ stealth: false });
Expand Down

1 comment on commit 0f18eda

@vercel
Copy link

@vercel vercel bot commented on 0f18eda Jan 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.