From f51bfaeb0c5b127f293479fcfa069c0083f5124a Mon Sep 17 00:00:00 2001 From: Kasper Date: Mon, 21 Feb 2022 21:53:34 +0800 Subject: [PATCH] feat(route): add nogizaka46 blog (#9161) * feat: add nogizaka46 blog * perf: use parseDate() * perf: specify guid --- docs/new-media.md | 4 ++++ lib/v2/nogizaka46/blog.js | 29 +++++++++++++++++++++++++++++ lib/v2/nogizaka46/maintainer.js | 1 + lib/v2/nogizaka46/radar.js | 12 ++++++++++-- lib/v2/nogizaka46/router.js | 1 + 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 lib/v2/nogizaka46/blog.js diff --git a/docs/new-media.md b/docs/new-media.md index a6c29fc25b..7f241a99d3 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1232,6 +1232,10 @@ Supported sub-sites: +### 乃木坂 46 博客 + + + ### 欅坂 46 新闻 diff --git a/lib/v2/nogizaka46/blog.js b/lib/v2/nogizaka46/blog.js new file mode 100644 index 0000000000..337110a898 --- /dev/null +++ b/lib/v2/nogizaka46/blog.js @@ -0,0 +1,29 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); + +const rootUrl = 'https://www.nogizaka46.com'; + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: `${rootUrl}/s/n46/api/list/blog`, + }); + + const list = JSON.parse(response.data.slice(4).slice(0, -2)).data; + + ctx.state.data = { + allowEmpty: true, + title: '乃木坂46 公式ブログ', + link: 'https://www.nogizaka46.com/s/n46/diary/MEMBER', + item: + list && + list.map((item) => ({ + title: item.title, + link: item.link, + pubDate: parseDate(item.date), + author: item.name, + description: item.text, + guid: rootUrl + new URL(item.link).pathname, + })), + }; +}; diff --git a/lib/v2/nogizaka46/maintainer.js b/lib/v2/nogizaka46/maintainer.js index c825d22f25..01b4642bb0 100644 --- a/lib/v2/nogizaka46/maintainer.js +++ b/lib/v2/nogizaka46/maintainer.js @@ -1,3 +1,4 @@ module.exports = { '/news': ['crispgm', 'Fatpandac'], + '/blog': ['Kasper4649'], }; diff --git a/lib/v2/nogizaka46/radar.js b/lib/v2/nogizaka46/radar.js index dece9922b0..794eb97fcc 100644 --- a/lib/v2/nogizaka46/radar.js +++ b/lib/v2/nogizaka46/radar.js @@ -1,13 +1,21 @@ module.exports = { 'nogizaka46.com': { _name: '乃木坂46', - '.': [ + news: [ { title: '新闻', docs: 'https://docs.rsshub.app/new-media.html#ban-dao-xi-lie-guan-wang-zi-xun-nai-mu-ban-46-xin-wen', - source: ['/', '/s/n46/news/list'], + source: ['/s/n46/news/list'], target: '/nogizaka46/news', }, ], + blog: [ + { + title: '博客', + docs: 'https://docs.rsshub.app/new-media.html#ban-dao-xi-lie-guan-wang-zi-xun-nai-mu-ban-46-bo-ke', + source: ['/s/n46/diary/MEMBER'], + target: '/nogizaka46/blog', + }, + ], }, }; diff --git a/lib/v2/nogizaka46/router.js b/lib/v2/nogizaka46/router.js index 69a5972f6a..d0c2b64634 100644 --- a/lib/v2/nogizaka46/router.js +++ b/lib/v2/nogizaka46/router.js @@ -1,3 +1,4 @@ module.exports = function (router) { router.get('/news', require('./news')); + router.get('/blog', require('./blog')); };