From a072942c28d34be57ef26503f87589f192fb1db8 Mon Sep 17 00:00:00 2001 From: Devin Date: Tue, 23 Aug 2022 02:45:19 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E3=82=A2=E3=83=8B?= =?UTF-8?q?=E3=83=A1=E6=96=B0=E7=95=AA=E7=B5=84=20(#10559)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add アニメ新番組 * Delete and modify character symbols * Using art-template * Modify url hash * Define art and path * Change back to post method * Modify the post method * feat(route): add アニメ新番組 * fix: typo --- docs/anime.md | 6 ++++++ lib/v2/bangumi/maintainer.js | 1 + lib/v2/bangumi/online.js | 26 ++++++++++++++++++++++++++ lib/v2/bangumi/radar.js | 15 +++++++++++++-- lib/v2/bangumi/router.js | 1 + lib/v2/bangumi/templates/image.art | 1 + 6 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 lib/v2/bangumi/online.js create mode 100644 lib/v2/bangumi/templates/image.art diff --git a/docs/anime.md b/docs/anime.md index 1f52d8e59..33d7f8782 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -652,3 +652,9 @@ Sources ### 最新汉化 + +## アニメ新番組 + +### 當季新番 + + diff --git a/lib/v2/bangumi/maintainer.js b/lib/v2/bangumi/maintainer.js index b4a30df31..52659f4b7 100644 --- a/lib/v2/bangumi/maintainer.js +++ b/lib/v2/bangumi/maintainer.js @@ -1,4 +1,5 @@ module.exports = { + '/online': ['devinmugen'], '/': ['nczitzk'], '/:tags?': ['nczitzk'], }; diff --git a/lib/v2/bangumi/online.js b/lib/v2/bangumi/online.js new file mode 100644 index 000000000..658e2b603 --- /dev/null +++ b/lib/v2/bangumi/online.js @@ -0,0 +1,26 @@ +const got = require('@/utils/got'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const url = 'https://bangumi.online/api/home'; + + const response = await got.post(url); + + const list = response.data.data.list; + + const items = list.map((item) => ({ + title: `${item.title_zh} - 第 ${item.volume} 集`, + description: art(path.join(__dirname, 'templates/image.art'), { + src: `https:${item.cover}`, + alt: `${item.title_zh} - 第 ${item.volume} 集`, + }), + link: `https://bangumi.online/watch/${item.vid}`, + })); + + ctx.state.data = { + title: 'アニメ新番組', + link: 'https://bangumi.online', + item: items, + }; +}; diff --git a/lib/v2/bangumi/radar.js b/lib/v2/bangumi/radar.js index 98c9fbc76..eea70864b 100644 --- a/lib/v2/bangumi/radar.js +++ b/lib/v2/bangumi/radar.js @@ -1,6 +1,6 @@ module.exports = { - '萌番组 Bangumi Moe': { - _name: 'bangumi.moe', + 'bangumi.moe': { + _name: '萌番組', '.': [ { title: '最新', @@ -16,4 +16,15 @@ module.exports = { }, ], }, + 'bangumi.online': { + _name: 'アニメ新番組', + '.': [ + { + title: '當季新番', + docs: 'https://docs.rsshub.app/anime.html#アニメ-xin-fan-zu-dang-ji-xin-fan', + source: ['/'], + target: '/bangumi/online', + }, + ], + }, }; diff --git a/lib/v2/bangumi/router.js b/lib/v2/bangumi/router.js index 406315685..5c90781a2 100644 --- a/lib/v2/bangumi/router.js +++ b/lib/v2/bangumi/router.js @@ -1,3 +1,4 @@ module.exports = function (router) { + router.get('/online', require('./online')); router.get(/([\w-/]+)?/, require('./index')); }; diff --git a/lib/v2/bangumi/templates/image.art b/lib/v2/bangumi/templates/image.art new file mode 100644 index 000000000..40140a947 --- /dev/null +++ b/lib/v2/bangumi/templates/image.art @@ -0,0 +1 @@ +{{ alt }}