From 45883a94b31561deacc7d6765185c3ea6915c37b Mon Sep 17 00:00:00 2001 From: zytomorrow Date: Thu, 16 Feb 2023 20:19:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=E9=A3=8E?= =?UTF-8?q?=E4=B9=8B=E5=8A=A8=E6=BC=AB=20(#11873)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(route): 修复风之动漫 * fix(route): 修复风之动漫 * fix(route): 修复风之动漫 * fix(route): 修复风之动漫 * Update lib/v2/fzdm/manhua/manhua.js * Update lib/v2/fzdm/manhua/manhua.js * fix(route): 修复风之动漫 * Update lib/v2/fzdm/radar.js * fix(route): 修复风之动漫 * Update lib/v2/fzdm/manhua/manhua.js * Update lib/v2/fzdm/manhua/manhua.js * Update lib/v2/fzdm/manhua/manhua.js * Update lib/v2/fzdm/manhua/manhua.js * fix: update route path --------- Co-authored-by: zytomorrow --- docs/anime.md | 4 +- lib/router.js | 2 +- lib/routes/fzdm/manhua.js | 62 ------------------------------- lib/v2/fffdm/maintainer.js | 3 ++ lib/v2/fffdm/manhua/manhua.js | 55 +++++++++++++++++++++++++++ lib/v2/fffdm/radar.js | 14 +++++++ lib/v2/fffdm/router.js | 3 ++ lib/v2/fffdm/templates/manhua.art | 5 +++ 8 files changed, 83 insertions(+), 65 deletions(-) delete mode 100644 lib/routes/fzdm/manhua.js create mode 100644 lib/v2/fffdm/maintainer.js create mode 100644 lib/v2/fffdm/manhua/manhua.js create mode 100644 lib/v2/fffdm/radar.js create mode 100644 lib/v2/fffdm/router.js create mode 100644 lib/v2/fffdm/templates/manhua.art diff --git a/docs/anime.md b/docs/anime.md index db17c55dad..cfac9ad97f 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -592,9 +592,9 @@ Sources ## 风之动漫 -### 风之动漫 +### 在线漫画 - + ## 海猫吧 diff --git a/lib/router.js b/lib/router.js index e6999b740d..f2e6240350 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2800,7 +2800,7 @@ router.get('/grubstreet', lazyloadRouteHandler('./routes/grubstreet/index')); router.get('/manhuadui/manhua/:name/:serial?', lazyloadRouteHandler('./routes/manhuadui/manhua')); // 风之漫画 -router.get('/fzdm/manhua/:id', lazyloadRouteHandler('./routes/fzdm/manhua')); +// router.get('/fzdm/manhua/:id', lazyloadRouteHandler('./routes/fzdm/manhua')); // Aljazeera 半岛网 // router.get('/aljazeera/news', lazyloadRouteHandler('./routes/aljazeera/news')); diff --git a/lib/routes/fzdm/manhua.js b/lib/routes/fzdm/manhua.js deleted file mode 100644 index 7368cdab1a..0000000000 --- a/lib/routes/fzdm/manhua.js +++ /dev/null @@ -1,62 +0,0 @@ -const got = require('@/utils/got'); -const domain = 'manhua.fffdm.com'; -const host = `https://${domain}`; -const picHost = 'https://p5.fzacg.com'; -const cheerio = require('cheerio'); - -const get_pic = (id, chapert, caches) => { - const picUrlPattern = RegExp(/var mhurl = "(.*?)";/); - return caches.tryGet(`${host}/${id}/${chapert}/`, async () => { - let is_last_page = false; - let index = 0; - let pic_content = ''; - while (!is_last_page) { - // eslint-disable-next-line no-await-in-loop - const response = await got.get(`${host}/${id}/${chapert}/index_${index}.html`); - const data = response.data; - if (response.data !== undefined) { - const picurl = data.match(picUrlPattern); - pic_content += `
`; - if (data.match('最后一页了') !== null) { - is_last_page = true; - } - } else { - pic_content += ''; - is_last_page = true; - } - - index += 1; - } - return pic_content; - }); -}; - -module.exports = async (ctx) => { - const id = ctx.params.id; - const count = ctx.query.limit || 99999; - const comicPage = host + `/${id}/`; - const response = await got({ - method: 'get', - url: comicPage, - }); - const data = response.data; - const $ = cheerio.load(data); - const list = $('div#content > li > a').toArray(); - const comicTitle = $('div#content > img').attr('alt').replace(/漫画/, ''); - const chapter_detail = await Promise.all( - list.splice(0, count).map(async (item) => { - const pic_content = await get_pic(id, $(item).attr('href').replace('/', ''), ctx.cache); - return { - title: $(item).text().trim(), - description: pic_content, - link: `${comicPage}${item.attribs.href}`, - }; - }) - ); - ctx.state.data = { - title: '风之动漫 - ' + comicTitle, - link: comicPage, - description: '风之动漫', - item: chapter_detail, - }; -}; diff --git a/lib/v2/fffdm/maintainer.js b/lib/v2/fffdm/maintainer.js new file mode 100644 index 0000000000..81e83db3ce --- /dev/null +++ b/lib/v2/fffdm/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/manhua/:id/:cdn?': ['zytomorrow'], +}; diff --git a/lib/v2/fffdm/manhua/manhua.js b/lib/v2/fffdm/manhua/manhua.js new file mode 100644 index 0000000000..fde99cbb25 --- /dev/null +++ b/lib/v2/fffdm/manhua/manhua.js @@ -0,0 +1,55 @@ +const got = require('@/utils/got'); +const domain = 'manhua.fffdm.com'; +const host = `https://${domain}`; +const { art } = require('@/utils/render'); +const path = require('path'); +const { parseDate } = require('@/utils/parse-date'); + +const get_pic = async (url) => { + const response = await got(url); + const data = response.data; + return { + comicTitle: data.mhinfo.title, + chapterTitle: data.title, + pics: data.cont, + pubDate: parseDate(data.mh.time), + }; +}; + +module.exports = async (ctx) => { + const id = ctx.params.id; + const count = ctx.query.limit || 99999; + const cdnNum = ctx.params.cdn || 5; + let cdn = ''; + if (!isNaN(parseInt(cdnNum)) && 1 <= parseInt(cdnNum) && parseInt(cdnNum) <= 5) { + cdn = `https://p${cdnNum}.fzacg.com`; + } else { + cdn = `https://p5.fzacg.com`; + } + + // 获取漫画清单 + const response = await got(`${host}/api/manhua/${id}`); + const data = response.data; + + const chapter_detail = await Promise.all( + data.mhlist.splice(0, count).map((item) => { + const url = `${host}/api/manhua/${id}/${item.url}`; + return ctx.cache.tryGet(url, async () => { + const picContent = await get_pic(url); + return { + title: picContent.chapterTitle, + description: art(path.join(__dirname, '../templates/manhua.art'), { pic: picContent.pics, cdn }), + link: `${host}/${id}/${item.url}/`, + comicTitle: picContent.comicTitle, + pubDate: picContent.pubDate, + }; + }); + }) + ); + ctx.state.data = { + title: '风之动漫 - ' + chapter_detail[0].comicTitle, + link: `${host}/${id}`, + description: '风之动漫', + item: chapter_detail, + }; +}; diff --git a/lib/v2/fffdm/radar.js b/lib/v2/fffdm/radar.js new file mode 100644 index 0000000000..92f932ffd7 --- /dev/null +++ b/lib/v2/fffdm/radar.js @@ -0,0 +1,14 @@ +const fffdm = { + title: '在线漫画', + docs: 'https://docs.rsshub.app/anime.html#feng-zhi-dong-man', + source: ['/manhua/:id', '/:id'], + target: '/fffdm/manhua/:id', +}; + +module.exports = { + 'fffdm.com': { + _name: '风之动漫', + manhua: fffdm, + www: fffdm, + }, +}; diff --git a/lib/v2/fffdm/router.js b/lib/v2/fffdm/router.js new file mode 100644 index 0000000000..568b224379 --- /dev/null +++ b/lib/v2/fffdm/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/manhua/:id/:cdn?', require('./manhua/manhua')); +}; diff --git a/lib/v2/fffdm/templates/manhua.art b/lib/v2/fffdm/templates/manhua.art new file mode 100644 index 0000000000..a5a76ff817 --- /dev/null +++ b/lib/v2/fffdm/templates/manhua.art @@ -0,0 +1,5 @@ +
+ {{ each pic }} +
+ {{/each }} +