From d97836ea12be99a925b42b32644ce4e1c00bf1ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Summer=E2=9B=B1?= <57806936+honue@users.noreply.github.com> Date: Fri, 17 Nov 2023 22:16:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20Bangumi=20=E6=88=90?= =?UTF-8?q?=E5=91=98=E5=85=B3=E6=B3=A8=E5=8A=A8=E7=94=BB=E6=A6=9C=20(#1381?= =?UTF-8?q?8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(route): add Bangumi 成员关注动画榜 * fix * Update lib/v2/bangumi/tv/other/followrank.js Co-authored-by: Tony * Update website/docs/routes/anime.mdx Co-authored-by: Tony * Update router.js * Update router.js * Update followrank.js * Update followrank.js * fix --------- --- lib/v2/bangumi/maintainer.js | 1 + lib/v2/bangumi/radar.js | 6 ++++ lib/v2/bangumi/router.js | 1 + lib/v2/bangumi/tv/other/followrank.js | 42 +++++++++++++++++++++++++++ website/docs/routes/anime.mdx | 4 +++ 5 files changed, 54 insertions(+) create mode 100644 lib/v2/bangumi/tv/other/followrank.js diff --git a/lib/v2/bangumi/maintainer.js b/lib/v2/bangumi/maintainer.js index 2e0def8ef2..ecd753921d 100644 --- a/lib/v2/bangumi/maintainer.js +++ b/lib/v2/bangumi/maintainer.js @@ -6,6 +6,7 @@ module.exports = { '/online': ['devinmugen'], // bangumi.tv '/tv/calendar/today': ['magic-akari'], + '/tv/followrank': ['honue'], '/tv/group/:id': ['SettingDust'], '/tv/person/:id': ['ylc395'], '/tv/subject/:id': ['SettingDust'], diff --git a/lib/v2/bangumi/radar.js b/lib/v2/bangumi/radar.js index dcd2cebc89..a78bc0224b 100644 --- a/lib/v2/bangumi/radar.js +++ b/lib/v2/bangumi/radar.js @@ -55,6 +55,12 @@ const bangumiTV = { source: '/calendar', target: '/bangumi/tv/calendar/today', }, + { + title: '成员关注动画榜', + docs: 'https://docs.rsshub.app/routes/anime#bangumi-fan-zu-ji-hua', + source: '/anime', + target: '/bangumi/tv/followrank', + }, ], }; diff --git a/lib/v2/bangumi/router.js b/lib/v2/bangumi/router.js index 3d1ab6c7d5..41bed50eb9 100644 --- a/lib/v2/bangumi/router.js +++ b/lib/v2/bangumi/router.js @@ -5,6 +5,7 @@ module.exports = function (router) { router.get('/online', require('./online/online')); // bangumi.tv router.get('/tv/calendar/today', require('./tv/calendar/today')); + router.get('/tv/followrank', require('./tv/other/followrank')); router.get('/tv/group/:id', require('./tv/group/topic')); router.get('/tv/person/:id', require('./tv/person')); router.get('/tv/subject/:id/:type?/:showOriginalName?', require('./tv/subject')); diff --git a/lib/v2/bangumi/tv/other/followrank.js b/lib/v2/bangumi/tv/other/followrank.js new file mode 100644 index 0000000000..8fb45d9869 --- /dev/null +++ b/lib/v2/bangumi/tv/other/followrank.js @@ -0,0 +1,42 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const config = require('@/config').value; +module.exports = async (ctx) => { + const url = 'https://bgm.tv/anime'; + const response = await got({ + url, + method: 'get', + headers: { + 'User-Agent': config.trueUA, + }, + }); + + const $ = cheerio.load(response.body); + + const items = $('#columnB > div:nth-child(4) > table > tbody') + .find('tr') + .toArray() + .map((item) => { + const aTag = $(item).children('td').next().find('a'); + return { + title: aTag.html(), + link: 'https://bgm.tv' + aTag.attr('href'), + }; + }) + .concat( + $('#chl_subitem > ul') + .find('li') + .toArray() + .map((item) => ({ + title: $(item).children('a').attr('title'), + link: 'https://bgm.tv' + $(item).children('a').attr('href'), + })) + ); + + ctx.state.data = { + title: 'Bangumi 成员关注动画榜', + link: url, + item: items, + description: `Bangumi 首页-成员关注动画榜`, + }; +}; diff --git a/website/docs/routes/anime.mdx b/website/docs/routes/anime.mdx index b3a0e2e023..f6ccb69777 100644 --- a/website/docs/routes/anime.mdx +++ b/website/docs/routes/anime.mdx @@ -203,6 +203,10 @@ For more tags, please go to [Search torrent](https://bangumi.moe/search/index) +### 成员关注动画榜 {#bangumi-cheng-yuan-guan-zhu-dong-hua-bang} + + + ## CCC 創作集 {#ccc-chuang-zuo-ji} ### 漫畫 {#ccc-chuang-zuo-ji-man-hua}