diff --git a/docs/game.md b/docs/game.md
index 9d3cc93063..9c13ab93e4 100644
--- a/docs/game.md
+++ b/docs/game.md
@@ -42,7 +42,15 @@ pageClass: routes
### eShop 新发售游戏
-
+
+
+### 首页资讯(香港)
+
+
+
+### 直面会
+
+
## PlayStation Store
diff --git a/lib/router.js b/lib/router.js
index 2b1de87cfa..f6c61d35b8 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -1231,6 +1231,8 @@ router.get('/ps/list/:gridName', require('./routes/ps/list'));
router.get('/nintendo/eshop/jp', require('./routes/nintendo/eshop_jp'));
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('/who/news-room/:type', require('./routes/who/news-room'));
diff --git a/lib/routes/nintendo/direct.js b/lib/routes/nintendo/direct.js
new file mode 100644
index 0000000000..ee2d4329cc
--- /dev/null
+++ b/lib/routes/nintendo/direct.js
@@ -0,0 +1,40 @@
+const axios = require('@/utils/axios');
+const cheerio = require('cheerio');
+
+module.exports = async (ctx) => {
+ const response = await axios({
+ method: 'get',
+ url: 'https://www.nintendo.com/nintendo-direct/archive/',
+ });
+ const data = response.data;
+
+ const $ = cheerio.load(data);
+ const list = $('.news-tiles li')
+ .get()
+ .slice(0, 9);
+
+ const result = list.map((item) => {
+ const $ = cheerio.load(item);
+ return {
+ title: $('.b7').html(),
+ cover: $('img ')
+ .attr('src')
+ .replace('../', 'https://www.nintendo.com/nintendo-direct/'),
+ des: $('p').html(),
+ url: $('a')
+ .attr('href')
+ .replace('../', 'https://www.nintendo.com/nintendo-direct/'),
+ };
+ });
+
+ ctx.state.data = {
+ title: `Nintendo Direct (任天堂直面会)`,
+ link: `https://www.nintendo.com/nintendo-direct/archive/`,
+ description: `最新的任天堂直面会日程信息`,
+ item: result.map((item) => ({
+ title: item.title,
+ description: `
${item.des}`,
+ link: item.url,
+ })),
+ };
+};
diff --git a/lib/routes/nintendo/news.js b/lib/routes/nintendo/news.js
new file mode 100644
index 0000000000..a2a6512ec2
--- /dev/null
+++ b/lib/routes/nintendo/news.js
@@ -0,0 +1,25 @@
+const axios = require('@/utils/axios');
+const util = require('./utils');
+
+module.exports = async (ctx) => {
+ const response = await axios({
+ method: 'get',
+ url: `https://www.nintendo.com.hk/data/json/topics.json`,
+ });
+ const data = response.data.filter((val) => val.only_for !== 'tw' && val.url.startsWith('/topics/article/')).slice(0, 9);
+
+ // 获取新闻正文
+ const result = await util.ProcessNews(data, ctx.cache);
+
+ ctx.state.data = {
+ title: `Nintendo (香港) 主页资讯`,
+ link: `https://www.nintendo.com.hk/topics/index.html`,
+ description: `Nintendo香港有限公司官网刊登的资讯`,
+ item: result.map((item) => ({
+ title: item.title,
+ description: item.content,
+ link: `https://www.nintendo.com.hk${item.url}`,
+ pubDate: item.data,
+ })),
+ };
+};
diff --git a/lib/routes/nintendo/utils.js b/lib/routes/nintendo/utils.js
index 338ec1e6b4..fc77ef3486 100644
--- a/lib/routes/nintendo/utils.js
+++ b/lib/routes/nintendo/utils.js
@@ -15,6 +15,24 @@ async function load(link) {
return { content: description };
}
+async function loadNews(link) {
+ const response = await axios({
+ method: 'get',
+ url: link,
+ });
+
+ const data = response.data;
+
+ const $ = cheerio.load(data);
+ let description = $('.detail-body-container').html();
+ const date = $('.topics-articleHead__date').html();
+ description = description.replace(new RegExp('src="/topics/', 'g'), ' referrerpolicy="no-referrer" src="https://www.nintendo.com.hk/topics/');
+ return {
+ content: description,
+ date: new Date(date).toUTCString(),
+ };
+}
+
const ProcessItem = async (list, caches) =>
await Promise.all(
list.map(async (item) => {
@@ -23,6 +41,15 @@ const ProcessItem = async (list, caches) =>
})
);
+const ProcessNews = async (list, caches) =>
+ await Promise.all(
+ list.map(async (item) => {
+ const other = await caches.tryGet(item.link, async () => await loadNews('https://www.nintendo.com.hk' + item.url));
+ return Promise.resolve(Object.assign({}, item, other));
+ })
+ );
+
module.exports = {
ProcessItem,
+ ProcessNews,
};