diff --git a/docs/game.md b/docs/game.md index 82b4474046..5b053648a2 100644 --- a/docs/game.md +++ b/docs/game.md @@ -100,6 +100,10 @@ pageClass: routes +### Switch 本体更新情报(日本) + + + ## PlayStation ### PlayStation Store 游戏列表 diff --git a/lib/router.js b/lib/router.js index b589621002..47f370d3e8 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1364,6 +1364,7 @@ router.get('/nintendo/eshop/hk', require('./routes/nintendo/eshop_hk')); router.get('/nintendo/eshop/us', require('./routes/nintendo/eshop_us')); router.get('/nintendo/news', require('./routes/nintendo/news')); router.get('/nintendo/direct', require('./routes/nintendo/direct')); +router.get('/nintendo/system-update', require('./routes/nintendo/system-update')); // 世界卫生组织 router.get('/who/news-room/:type', require('./routes/who/news-room')); diff --git a/lib/routes/nintendo/system-update.js b/lib/routes/nintendo/system-update.js new file mode 100644 index 0000000000..40dfc28ab2 --- /dev/null +++ b/lib/routes/nintendo/system-update.js @@ -0,0 +1,40 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'https://www.nintendo.co.jp/support/switch/system_update/index.html'; + + const response = await got.get(url); + const $ = cheerio.load(response.data); + + const list = $('#latest > .c-heading-lv3') + .toArray() + .slice(1); + + ctx.state.data = { + title: 'Nintendo Switch 本体更新情報', + link: url, + item: list.map((update) => { + update = $(update); + const heading = update.text(); + const matched_date = /(\d+)年(\d+)月(\d+)日/.exec(heading); + const update_info = update.nextUntil('.c-heading-lv3'); + const update_infos = update_info + .map(function() { + return $(this).html(); + }) + .get() + .join('\n'); + const matched_version = /(\d\.)+\d/.exec(heading); + + return { + title: heading, + author: 'Nintendo', + description: update_infos, + link: url, + guid: `${url}#${matched_version[0]}`, + pubDate: new Date(parseInt(matched_date[1]), parseInt(matched_date[2]) - 1, parseInt(matched_date[3])), + }; + }), + }; +};