From d20fbff489a4c62261e1b58814bebd1f197e1d99 Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Thu, 10 Dec 2020 22:05:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=93=94=E5=93=A9=E5=93=94=E5=93=A9?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=83=85=E6=8A=A5=20(#6394)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/program-update.md | 10 ++++++++++ lib/router.js | 1 + lib/routes/bilibili/app.js | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 lib/routes/bilibili/app.js diff --git a/docs/program-update.md b/docs/program-update.md index 135fae45ab..e48fab8577 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -54,6 +54,16 @@ pageClass: routes +## Bilibili + +### 更新情报 + + + +| 安卓版 | iPhone 版 | iPad HD 版 | UWP 版 | TV 版 | +| ------- | --------- | ---------- | ------ | -------------- | +| android | iphone | ipad | win | android_tv_yst | + ## Bandisoft ### 更新记录 diff --git a/lib/router.js b/lib/router.js index 4d18e6df37..a1f44f3812 100644 --- a/lib/router.js +++ b/lib/router.js @@ -86,6 +86,7 @@ router.get('/bilibili/readlist/:listid', require('./routes/bilibili/readlist')); router.get('/bilibili/weekly', require('./routes/bilibili/weekly_recommend')); router.get('/bilibili/manga/update/:comicid', require('./routes/bilibili/manga_update')); router.get('/bilibili/followings/dynamic/:uid/:disableEmbed?', require('./routes/bilibili/followings_dynamic')); +router.get('/bilibili/app/:id?', require('./routes/bilibili/app')); // bangumi router.get('/bangumi/calendar/today', require('./routes/bangumi/calendar/today')); diff --git a/lib/routes/bilibili/app.js b/lib/routes/bilibili/app.js new file mode 100644 index 0000000000..c78062c1b8 --- /dev/null +++ b/lib/routes/bilibili/app.js @@ -0,0 +1,33 @@ +const got = require('@/utils/got'); + +const config = { + android: '安卓版', + iphone: 'iPhone 版', + ipad: 'iPad HD 版', + win: 'UWP 版', + android_tv_yst: 'TV 版', +}; + +module.exports = async (ctx) => { + const id = ctx.params.id || 'android'; + + const rootUrl = 'https://app.bilibili.com'; + const apiUrl = `${rootUrl}/x/v2/version?mobi_app=${id}`; + const response = await got({ + method: 'get', + url: apiUrl, + }); + + const items = response.data.data.map((item) => ({ + link: rootUrl, + title: item.version, + pubDate: new Date(item.ptime * 1000).toUTCString(), + description: `
  • ${item.desc.split('\n-').join('
  • -')}
  • `, + })); + + ctx.state.data = { + title: `哔哩哔哩更新情报 - ${config[id]}`, + link: rootUrl, + item: items, + }; +};