From 70b4385bf1f97ef849264e3e476925a7f4b15dd9 Mon Sep 17 00:00:00 2001 From: Tony Date: Sun, 21 Jan 2024 16:03:51 +0000 Subject: [PATCH] feat(route): laimanhua (#14297) --- lib/v2/laimanhua/index.js | 41 ++++++++++++++++++++++++++++++++++ lib/v2/laimanhua/maintainer.js | 3 +++ lib/v2/laimanhua/radar.js | 13 +++++++++++ lib/v2/laimanhua/router.js | 3 +++ website/docs/routes/anime.mdx | 6 +++++ 5 files changed, 66 insertions(+) create mode 100644 lib/v2/laimanhua/index.js create mode 100644 lib/v2/laimanhua/maintainer.js create mode 100644 lib/v2/laimanhua/radar.js create mode 100644 lib/v2/laimanhua/router.js diff --git a/lib/v2/laimanhua/index.js b/lib/v2/laimanhua/index.js new file mode 100644 index 000000000..98440a2b7 --- /dev/null +++ b/lib/v2/laimanhua/index.js @@ -0,0 +1,41 @@ +const got = require('@/utils/got'); +const iconv = require('iconv-lite'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const { id } = ctx.params; + const baseUrl = `https://www.laimanhua8.com`; + const link = `${baseUrl}/kanmanhua/${id}/`; + + const { data: response } = await got(link, { + responseType: 'buffer', + }); + let $ = cheerio.load(iconv.decode(response, 'utf-8')); + const charset = $('meta[http-equiv="Content-Type"]') + .attr('content') + ?.match(/charset=(.*)/)?.[1]; + if (charset?.toLowerCase() !== 'utf-8') { + $ = cheerio.load(iconv.decode(response, charset ?? 'utf-8')); + } + + const items = $('.plist a') + .toArray() + .map((item, index) => { + item = $(item); + return { + title: item.attr('title'), + link: `${baseUrl}${item.attr('href')}`, + pubDate: index === 0 ? parseDate($('head meta[property="og:novel:update_time"]').attr('content')) : null, + author: $('head meta[property="og:novel:author"]').attr('content'), + }; + }); + + ctx.state.data = { + title: `${$('head meta[property="og:novel:book_name"]').attr('content')} - 来漫画`, + description: $('.introduction').text(), + image: $('head meta[property="og:image"]').attr('content'), + link, + item: items, + }; +}; diff --git a/lib/v2/laimanhua/maintainer.js b/lib/v2/laimanhua/maintainer.js new file mode 100644 index 000000000..23772fd7f --- /dev/null +++ b/lib/v2/laimanhua/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:id': ['TonyRL'], +}; diff --git a/lib/v2/laimanhua/radar.js b/lib/v2/laimanhua/radar.js new file mode 100644 index 000000000..1d4f054cf --- /dev/null +++ b/lib/v2/laimanhua/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'laimanhua8.com': { + _name: '来漫画', + www: [ + { + title: '漫画列表', + docs: 'https://docs.rsshub.app/routes/anime#lai-man-hua', + source: '/kanmanhua/:id', + target: '/laimanhua/:id', + }, + ], + }, +}; diff --git a/lib/v2/laimanhua/router.js b/lib/v2/laimanhua/router.js new file mode 100644 index 000000000..a9e414c85 --- /dev/null +++ b/lib/v2/laimanhua/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/:id', require('./index')); +}; diff --git a/website/docs/routes/anime.mdx b/website/docs/routes/anime.mdx index d03ea1026..8ecb005ee 100644 --- a/website/docs/routes/anime.mdx +++ b/website/docs/routes/anime.mdx @@ -694,6 +694,12 @@ You can use some RSS parsing libraries (like `feedpraser` in `Python`) to receiv +## 来漫画 {#lai-man-hua} + +### 漫画列表 {#lai-man-hua-man-hua-lie-biao} + + + ## 漫画 DB {#man-hua-db} ### 漫画 DB {#man-hua-db-man-hua-db}