更新拷贝漫画和漫画柜的返回数量控制功能,并且修复漫画柜一些bug (#8670)

Co-authored-by: 12051825 <liuzy20@spdb.com.cn>
This commit is contained in:
marvolo666 2022-01-23 03:02:39 +08:00 committed by GitHub
parent 3a23c00bf8
commit 75b9a49aab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 237 additions and 95 deletions

View File

@ -250,9 +250,10 @@
'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' }] },
'manhuagui.com': { _name: '漫画柜', www: [{ title: '漫画更新', docs: 'https://docs.rsshub.app/anime.html#kan-man-hua', source: '/comic/:id/', target: '/manhuagui/comic/:id' }] },
'mhgui.com': { _name: '漫画柜镜像站', www: [{ title: '漫画更新', docs: 'https://docs.rsshub.app/anime.html#kan-man-hua-jing-xiang-zhan', source: '/comic/:id/', target: '/mhgui/comic/:id' }] },
'manhuagui.com': { _name: '漫画柜', www: [{ title: '漫画更新', docs: 'https://docs.rsshub.app/anime.html#kan-man-hua', source: '/comic/:id/', target: '/manhuagui/comic/:id/5' }] },
'mhgui.com': { _name: '漫画柜镜像站', www: [{ title: '漫画更新', docs: 'https://docs.rsshub.app/anime.html#kan-man-hua-jing-xiang-zhan', source: '/comic/:id/', target: '/mhgui/comic/:id/5' }] },
'tw.manhuagui.com': { _name: '漫画柜台湾', www: [{ title: '漫画更新', docs: 'https://docs.rsshub.app/anime.html#kan-man-hua-tai-wan', source: '/comic/:id/', target: '/twmanhuagui/comic/: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' }] },
'pianyuan.la': { _name: '片源网', '.': [{ title: '电影和剧集', docs: 'https://docs.rsshub.app/multimedia.html#pian-yuan', source: '/' }] },
'sspai.com': {

View File

@ -407,25 +407,25 @@ Sources
### 漫画更新
<Route author="MegrezZhu" path="/manhuagui/comic/:id" example="/manhuagui/comic/22942" :paramsDesc="['漫画ID']" radar="1" rssbud="1"/>
<Route author="MegrezZhu" path="/manhuagui/comic/:id/:chapterCnt?" example="/manhuagui/comic/22942/5" :paramsDesc="['漫画ID','返回章节的数量默认为0返回所有章节']" radar="1" rssbud="1"/>
## 看漫画镜像站
### 漫画更新
<Route author="btdwv" path="/mhgui/comic/:id" example="/mhgui/comic/13317" :paramsDesc="['漫画ID']" radar="1" rssbud="1"/>
<Route author="btdwv" path="/mhgui/comic/:id/:chapterCnt?" example="/mhgui/comic/13317/5" :paramsDesc="['漫画ID','返回章节的数量默认为0返回所有章节']" 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="/twmanhuagui/comic/:id/:chapterCnt?" example="/twmanhuagui/comic/13317/5" :paramsDesc="['漫画ID','返回章节的数量默认为0返回所有章节']" radar="1" rssbud="1"/>
## 拷贝漫画
### 漫画更新
<Route author="btdwv" path="/copymanga/comic/:id" example="/copymanga/comic/zhandoupohuaixueyuandangerous" :paramsDesc="['漫画ID']" radar="1" rssbud="1"/>
<Route author="btdwv" path="/copymanga/comic/:id/:chapterCnt?" example="/copymanga/comic/zaiyishijiemigongkaihougong/5" :paramsDesc="['漫画ID','返回章节的数量默认为0返回所有章节']" radar="1" rssbud="1"/>
## 漫画 DB

View File

@ -1122,9 +1122,11 @@ router.get('/eeo/:column?/:category?', lazyloadRouteHandler('./routes/eeo/index'
router.get('/tencentvideo/playlist/:id', lazyloadRouteHandler('./routes/tencent/video/playlist'));
// 看漫画
router.get('/manhuagui/comic/:id', lazyloadRouteHandler('./routes/manhuagui/comic'));
router.get('/mhgui/comic/:id', lazyloadRouteHandler('./routes/mhgui/comic'));
router.get('/twmanhuagui/comic/:id', lazyloadRouteHandler('./routes/twmanhuagui/comic'));
router.get('/manhuagui/comic/:id/:chapterCnt?', lazyloadRouteHandler('./routes/manhuagui/comic'));
router.get('/mhgui/comic/:id/:chapterCnt?', lazyloadRouteHandler('./routes/mhgui/comic'));
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', lazyloadRouteHandler('./routes/copymanga/comic'));

View File

@ -4,7 +4,8 @@ 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;
@ -62,6 +63,6 @@ module.exports = async (ctx) => {
title: `拷贝漫画 - ${bookTitle}`,
link: `https://copymanga.com/comic/${id}`,
description: bookIntro,
item: chapterArray.map(genResult),
item: chapterArray.map(genResult).slice(0, chapterCnt),
};
};

View File

@ -3,23 +3,47 @@ const cheerio = require('cheerio');
const got = require('@/utils/got');
const LZString = require('lz-string');
const getChapters = ($) =>
$('.chapter-list > ul')
const getChapters = ($) => {
let time_mark = 100;
// 用于一次更新多个新章节的排序
let new_time_mark = 0;
return $('h4')
.toArray()
.reverse()
.reduce((acc, curr) => acc.concat($(curr).children('li').toArray()), [])
.map((ele) => {
const a = $(ele).children('a');
return {
link: resolve('https://www.manhuagui.com/', a.attr('href')),
title: a.attr('title'),
num: a.find('i').text(),
};
});
const categoryName = $(ele).text();
while (!$(ele.next).hasClass('chapter-list')) {
ele = ele.next;
}
ele = ele.next;
return $(ele)
.children('ul')
.toArray()
.reverse()
.reduce((acc, curr) => acc.concat($(curr).children('li').toArray()), [])
.map((ele) => {
const a = $(ele).children('a');
// 通过操作发布时间来对章节进行排序,如果是刚刚更新的单行本或者番外,保留最新更新时间
let pDate = new Date(new Date($.pubDate) - time_mark++ * 1000);
if (a.find('em').length > 0) {
// 对更新的章节也进行排序
pDate = new Date(new Date($.pubDate) - new_time_mark++ * 1000);
$.newChapterCnt++;
}
return {
link: resolve('https://www.manhuagui.com/', a.attr('href')),
title: a.attr('title'),
pub_date: pDate,
num: a.find('i').text(),
guid: resolve('https://www.manhuagui.com/', a.attr('href')),
category: categoryName,
};
});
})
.reduce((acc, curr) => acc.concat(curr));
};
module.exports = async (ctx) => {
const { id } = ctx.params;
const chapterCnt = Number(ctx.params.chapterCnt || 0);
const { data } = await got.get(`https://www.manhuagui.com/comic/${id}/`);
const $ = cheerio.load(data);
@ -30,24 +54,46 @@ module.exports = async (ctx) => {
$('#__VIEWSTATE').remove();
}
}
const bookTitle = $('.book-title > h1').text();
const bookIntro = $('#intro-all').text();
const coverImgSrc = $('.book-cover img').attr('src');
const chapters = getChapters($);
const genResult = (chapter) => ({
link: chapter.link,
title: chapter.title,
description: `
// 对最新更新的章节增加了pubDate
const reg = new RegExp('最近于.+更新至');
// 处理已下架的漫画
if ($('.status > span').text().indexOf('已下架') > 0) {
ctx.state.data = {
title: `看漫画 - ${bookTitle} 已下架`,
link: `https://www.manhuagui.com/comic/${id}/`,
description: bookIntro,
item: [{ link: `https://www.manhuagui.com/comic/${id}/`, title: bookTitle, description: '已下架' }],
};
} else {
const pub_date_str = $('.status > span').text().match(reg)[0].replace('最近于 [', '').replace('] 更新至', '');
// 为了能在闭包内访问到这个日期而不是每次需要处理这个最近更新日期
$.pubDate = new Date(pub_date_str).toUTCString();
$.newChapterCnt = 0;
const chapters = getChapters($);
const genResult = (chapter) => ({
link: chapter.link,
title: chapter.title,
pubDate: chapter.pub_date,
guid: chapter.guid,
category: chapter.category,
description: `
<h1>${chapter.num}</h1>
<img src="${coverImgSrc}" />
<img src='${coverImgSrc}' />
`.trim(),
});
ctx.state.data = {
title: `看漫画 - ${bookTitle}`,
link: `https://www.manhuagui.com/comic/${id}/`,
description: bookIntro,
item: chapters.map(genResult),
};
});
const items = chapters.map(genResult);
let itemsLen = items.length;
if (chapterCnt > 0) {
itemsLen = (chapterCnt < $.newChapterCnt) ? $.newChapterCnt : chapterCnt;
}
ctx.state.data = {
title: `看漫画 - ${bookTitle}`,
link: `https://www.manhuagui.com/comic/${id}/`,
description: bookIntro,
item: items.slice(0, itemsLen),
};
}
};

View File

@ -3,23 +3,47 @@ const cheerio = require('cheerio');
const got = require('@/utils/got');
const LZString = require('lz-string');
const getChapters = ($) =>
$('.chapter-list > ul')
const getChapters = ($) => {
let time_mark = 0;
// 用于一次更新多个新章节的排序
let new_time_mark = 0;
return $('h4')
.toArray()
.reverse()
.reduce((acc, curr) => acc.concat($(curr).children('li').toArray()), [])
.map((ele) => {
const a = $(ele).children('a');
return {
link: resolve('https://www.mhgui.com/', a.attr('href')),
title: a.attr('title'),
num: a.find('i').text(),
};
});
const categoryName = $(ele).text();
while (!$(ele.next).hasClass('chapter-list')) {
ele = ele.next;
}
ele = ele.next;
return $(ele)
.children('ul')
.toArray()
.reverse()
.reduce((acc, curr) => acc.concat($(curr).children('li').toArray()), [])
.map((ele) => {
const a = $(ele).children('a');
// 通过操作发布时间来对章节进行排序,如果是刚刚更新的单行本或者番外,保留最新更新时间
let pDate = new Date(new Date($.pubDate) - time_mark++ * 1000);
if (a.find('em').length > 0) {
// 对更新的章节也进行排序
pDate = new Date(new Date($.pubDate) - new_time_mark++ * 1000);
$.newChapterCnt++;
}
return {
link: resolve('https://www.mhgui.com/', a.attr('href')),
title: a.attr('title'),
pub_date: pDate,
num: a.find('i').text(),
guid: resolve('https://www.mhgui.com/', a.attr('href')),
category: categoryName,
};
});
})
.reduce((acc, curr) => acc.concat(curr));
};
module.exports = async (ctx) => {
const { id } = ctx.params;
const chapterCnt = Number(ctx.params.chapterCnt || 0);
const { data } = await got.get(`https://www.mhgui.com/comic/${id}/`);
const $ = cheerio.load(data);
@ -30,24 +54,46 @@ module.exports = async (ctx) => {
$('#__VIEWSTATE').remove();
}
}
const bookTitle = $('.book-title > h1').text();
const bookIntro = $('#intro-all').text();
const coverImgSrc = $('.book-cover img').attr('src');
const chapters = getChapters($);
const genResult = (chapter) => ({
link: chapter.link,
title: chapter.title,
description: `
// 对最新更新的章节增加了pubDate
const reg = new RegExp('最近于.+更新至');
// 处理已下架的漫画
if ($('.status > span').text().indexOf('已下架') > 0) {
ctx.state.data = {
title: `看漫画 - ${bookTitle} 已下架`,
link: `https://www.mhgui.com/comic/${id}/`,
description: bookIntro,
item: [{ link: `https://www.mhgui.com/comic/${id}/`, title: bookTitle, description: '已下架' }],
};
} else {
const pub_date_str = $('.status > span').text().match(reg)[0].replace('最近于 [', '').replace('] 更新至', '');
// 为了能在闭包内访问到这个日期而不是每次需要处理这个最近更新日期
$.pubDate = new Date(pub_date_str).toUTCString();
$.newChapterCnt = 0;
const chapters = getChapters($);
const genResult = (chapter) => ({
link: chapter.link,
title: chapter.title,
pubDate: chapter.pub_date,
guid: chapter.guid,
category: chapter.category,
description: `
<h1>${chapter.num}</h1>
<img src="${coverImgSrc}" />
<img src='${coverImgSrc}' />
`.trim(),
});
ctx.state.data = {
title: `看漫画 - ${bookTitle}`,
link: `https://www.mhgui.com/comic/${id}/`,
description: bookIntro,
item: chapters.map(genResult),
};
});
const items = chapters.map(genResult);
let itemsLen = items.length;
if (chapterCnt > 0) {
itemsLen = (chapterCnt < $.newChapterCnt) ? $.newChapterCnt : chapterCnt;
}
ctx.state.data = {
title: `看漫画 - ${bookTitle}`,
link: `https://www.mhgui.com/comic/${id}/`,
description: bookIntro,
item: items.slice(0, itemsLen),
};
}
};

View File

@ -3,23 +3,47 @@ const cheerio = require('cheerio');
const got = require('@/utils/got');
const LZString = require('lz-string');
const getChapters = ($) =>
$('.chapter-list > ul')
const getChapters = ($) => {
let time_mark = 0;
// 用于一次更新多个新章节的排序
let new_time_mark = 0;
return $('h4')
.toArray()
.reverse()
.reduce((acc, curr) => acc.concat($(curr).children('li').toArray()), [])
.map((ele) => {
const a = $(ele).children('a');
return {
link: resolve('https://tw.manhuagui.com/', a.attr('href')),
title: a.attr('title'),
num: a.find('i').text(),
};
});
const categoryName = $(ele).text();
while (!$(ele.next).hasClass('chapter-list')) {
ele = ele.next;
}
ele = ele.next;
return $(ele)
.children('ul')
.toArray()
.reverse()
.reduce((acc, curr) => acc.concat($(curr).children('li').toArray()), [])
.map((ele) => {
const a = $(ele).children('a');
// 通过操作发布时间来对章节进行排序,如果是刚刚更新的单行本或者番外,保留最新更新时间
let pDate = new Date(new Date($.pubDate) - time_mark++ * 1000);
if (a.find('em').length > 0) {
// 对更新的章节也进行排序
pDate = new Date(new Date($.pubDate) - new_time_mark++ * 1000);
$.newChapterCnt++;
}
return {
link: resolve('https://tw.manhuagui.com/', a.attr('href')),
title: a.attr('title'),
pub_date: pDate,
num: a.find('i').text(),
guid: resolve('https://tw.manhuagui.com/', a.attr('href')),
category: categoryName,
};
});
})
.reduce((acc, curr) => acc.concat(curr));
};
module.exports = async (ctx) => {
const { id } = ctx.params;
const chapterCnt = Number(ctx.params.chapterCnt || 0);
const { data } = await got.get(`https://tw.manhuagui.com/comic/${id}/`);
const $ = cheerio.load(data);
@ -30,24 +54,46 @@ module.exports = async (ctx) => {
$('#__VIEWSTATE').remove();
}
}
const bookTitle = $('.book-title > h1').text();
const bookIntro = $('#intro-all').text();
const coverImgSrc = $('.book-cover img').attr('src');
const chapters = getChapters($);
const genResult = (chapter) => ({
link: chapter.link,
title: chapter.title,
description: `
// 对最新更新的章节增加了pubDate
const reg = new RegExp('最近於.+更新至');
// 处理已下架的漫画
if ($('.status > span').text().indexOf('已下架') > 0) {
ctx.state.data = {
title: `看漫画 - ${bookTitle} 已下架`,
link: `https://tw.manhuagui.com/comic/${id}/`,
description: bookIntro,
item: [{ link: `https://tw.manhuagui.com/comic/${id}/`, title: bookTitle, description: '已下架' }],
};
} else {
const pub_date_str = $('.status > span').text().match(reg)[0].replace('最近於 [', '').replace('] 更新至', '');
// 为了能在闭包内访问到这个日期而不是每次需要处理这个最近更新日期
$.pubDate = new Date(pub_date_str).toUTCString();
$.newChapterCnt = 0;
const chapters = getChapters($);
const genResult = (chapter) => ({
link: chapter.link,
title: chapter.title,
pubDate: chapter.pub_date,
guid: chapter.guid,
category: chapter.category,
description: `
<h1>${chapter.num}</h1>
<img src="${coverImgSrc}" />
<img src='${coverImgSrc}' />
`.trim(),
});
ctx.state.data = {
title: `看漫画 - ${bookTitle}`,
link: `https://tw.manhuagui.com/comic/${id}/`,
description: bookIntro,
item: chapters.map(genResult),
};
});
const items = chapters.map(genResult);
let itemsLen = items.length;
if (chapterCnt > 0) {
itemsLen = (chapterCnt < $.newChapterCnt) ? $.newChapterCnt : chapterCnt;
}
ctx.state.data = {
title: `看漫画 - ${bookTitle}`,
link: `https://tw.manhuagui.com/comic/${id}/`,
description: bookIntro,
item: items.slice(0, itemsLen),
};
}
};