From 94f0d1ea9401014b013fccd369ed6df3bca9d852 Mon Sep 17 00:00:00 2001 From: Chris Wan Date: Tue, 13 Sep 2022 01:05:39 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20=E6=96=B0=E5=A2=9E=E5=A6=B9?= =?UTF-8?q?=E5=9B=BE=E7=A4=BE=20(#10760)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 新增妹图社 * feat: 新增妹图社文档 * feat: Remove markdown-it-attrs, since it breaks sidebar item title * feat: Use art template * fix: time parsing --- docs/en/picture.md | 6 ++++ docs/picture.md | 6 ++++ lib/v2/meituclub/latest.js | 41 ++++++++++++++++++++++ lib/v2/meituclub/maintainer.js | 3 ++ lib/v2/meituclub/radar.js | 13 +++++++ lib/v2/meituclub/router.js | 3 ++ lib/v2/meituclub/templates/description.art | 1 + 7 files changed, 73 insertions(+) create mode 100644 lib/v2/meituclub/latest.js create mode 100644 lib/v2/meituclub/maintainer.js create mode 100644 lib/v2/meituclub/radar.js create mode 100644 lib/v2/meituclub/router.js create mode 100644 lib/v2/meituclub/templates/description.art diff --git a/docs/en/picture.md b/docs/en/picture.md index 0f5b1bcc2..08d2e5519 100644 --- a/docs/en/picture.md +++ b/docs/en/picture.md @@ -208,6 +208,12 @@ For example: +## Meituclub + +### Latest + + + ## NASA Astronomy Picture of the Day ### NASA diff --git a/docs/picture.md b/docs/picture.md index 80bbc322f..3f0fb9eb2 100644 --- a/docs/picture.md +++ b/docs/picture.md @@ -554,6 +554,12 @@ R18 显示 +## 妹图社 + +### 最新 + + + ## 妹子图 ### 首页(最新) diff --git a/lib/v2/meituclub/latest.js b/lib/v2/meituclub/latest.js new file mode 100644 index 000000000..e05eec2b5 --- /dev/null +++ b/lib/v2/meituclub/latest.js @@ -0,0 +1,41 @@ +const path = require('path'); +const cheerio = require('cheerio'); +const got = require('@/utils/got'); +const { art } = require('@/utils/render'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +const HOME_URL = 'https://www.meituclub.com/'; + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: HOME_URL, + }); + + const data = response.data; + + const $ = cheerio.load(data); + const list = $('#index-tab-main .posts-item.card'); + + ctx.state.data = { + title: '妹图社 - 最新', + link: HOME_URL, + item: list + .map((index, item) => { + item = $(item); + const img = item.find('.item-thumbnail').find('img'); + const heading = item.find('.item-heading').find('a'); + return { + title: heading.text(), + description: art(path.join(__dirname, 'templates/description.art'), { + src: img.attr('data-src'), + alt: img.attr('alt'), + }), + link: heading.attr('href'), + pubDate: timezone(parseDate(item.find('.item-meta').find('.icon-circle').attr('title'), 'YYYY-MM-DD HH:mm:ss'), +8), + }; + }) + .get(), + }; +}; diff --git a/lib/v2/meituclub/maintainer.js b/lib/v2/meituclub/maintainer.js new file mode 100644 index 000000000..0a784e3fc --- /dev/null +++ b/lib/v2/meituclub/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/latest': ['ocleo1'], +}; diff --git a/lib/v2/meituclub/radar.js b/lib/v2/meituclub/radar.js new file mode 100644 index 000000000..6335bea68 --- /dev/null +++ b/lib/v2/meituclub/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'meituclub.com': { + _name: '妹图社', + '.': [ + { + title: '最新', + docs: 'https://docs.rsshub.app/picture.html#mei-tu-she-zui-xin', + source: ['/'], + target: '/meituclub/latest', + }, + ], + }, +}; diff --git a/lib/v2/meituclub/router.js b/lib/v2/meituclub/router.js new file mode 100644 index 000000000..c7599855e --- /dev/null +++ b/lib/v2/meituclub/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/latest', require('./latest')); +}; diff --git a/lib/v2/meituclub/templates/description.art b/lib/v2/meituclub/templates/description.art new file mode 100644 index 000000000..c961f7a31 --- /dev/null +++ b/lib/v2/meituclub/templates/description.art @@ -0,0 +1 @@ +{{ alt }} \ No newline at end of file