diff --git a/docs/anime.md b/docs/anime.md index 38170174cf..68fc264e70 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -616,6 +616,12 @@ Sources +## 番组放送 + +### 开播提醒 + + + ## 风之动漫 ### 在线漫画 diff --git a/lib/v2/bgmlist/maintainer.js b/lib/v2/bgmlist/maintainer.js new file mode 100644 index 0000000000..ab50127bd2 --- /dev/null +++ b/lib/v2/bgmlist/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/onair/:lang?': ['x2cf'], +}; diff --git a/lib/v2/bgmlist/onair.js b/lib/v2/bgmlist/onair.js new file mode 100644 index 0000000000..30e4b59ab8 --- /dev/null +++ b/lib/v2/bgmlist/onair.js @@ -0,0 +1,33 @@ +const got = require('@/utils/got'); +const path = require('path'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); + +module.exports = async (ctx) => { + const { lang } = ctx.params; + const siteLink = 'https://bgmlist.com/api/v1/bangumi/site'; + const sites = await ctx.cache.tryGet(siteLink, async () => (await got(siteLink)).data); + const { data } = await got('https://bgmlist.com/api/v1/bangumi/onair'); + + ctx.state.data = { + title: '番组放送 开播提醒', + link: 'https://bgmlist.com/', + item: data.items.map((item) => { + item.sites.push({ site: 'dmhy', id: item.titleTranslate['zh-Hans']?.[0] ?? item.title }); + return { + title: item.titleTranslate[lang]?.[0] ?? item.title, + link: item.officialSite, + description: art( + path.join(__dirname, 'templates/description.art'), + item.sites.map((site) => ({ + title: sites[site.site].title, + url: sites[site.site].urlTemplate.replaceAll('{{id}}', site.id), + begin: site.begin, + })) + ), + pubDate: parseDate(item.begin), + guid: item.id, + }; + }), + }; +}; diff --git a/lib/v2/bgmlist/radar.js b/lib/v2/bgmlist/radar.js new file mode 100644 index 0000000000..8666fb6c75 --- /dev/null +++ b/lib/v2/bgmlist/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'bgmlist.com': { + _name: '番组放送', + '.': [ + { + title: '开播提醒', + docs: 'https://docs.rsshub.app/anime.html#fan-zu-fang-song', + source: ['/'], + target: '/bgmlist/onair/zh-Hans', + }, + ], + }, +}; diff --git a/lib/v2/bgmlist/router.js b/lib/v2/bgmlist/router.js new file mode 100644 index 0000000000..5d7f99639c --- /dev/null +++ b/lib/v2/bgmlist/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/onair/:lang?', require('./onair')); +}; diff --git a/lib/v2/bgmlist/templates/description.art b/lib/v2/bgmlist/templates/description.art new file mode 100644 index 0000000000..10dbb3d979 --- /dev/null +++ b/lib/v2/bgmlist/templates/description.art @@ -0,0 +1,4 @@ +{{each}} +{{$value.title}}{{if $value.begin}}(开播时间:{{$value.begin}}){{/if}} +
+{{/each}}