mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 12:21:31 +08:00
feat: 任天堂eShop (#2136)
This commit is contained in:
@@ -38,6 +38,12 @@ pageClass: routes
|
||||
|
||||
<Route author="GensouSakuya" example="/indienova/article" path="indienova/article"/>
|
||||
|
||||
## Nintendo
|
||||
|
||||
### eShop 新发售游戏
|
||||
|
||||
<Route author="Aaron Liu" example="/nintendo/eshop/hk" path="/nintendo/eshop/:region" :paramsDesc="['地区标识,可为`hk`(港服),`jp`(日服),`us`(美服)']"/>
|
||||
|
||||
## PlayStation Store
|
||||
|
||||
### 游戏列表
|
||||
@@ -53,6 +59,7 @@ pageClass: routes
|
||||
### 首页-白金攻略/游戏开箱
|
||||
|
||||
<Route author="LightStrawberry" example="/psnine/index" path="/psnine/index"/>
|
||||
|
||||
### 新闻-游戏资讯
|
||||
|
||||
<Route author="LightStrawberry" example="/psnine/news" path="/psnine/news"/>
|
||||
|
||||
@@ -1307,6 +1307,11 @@ router.get('/mlhang', require('./routes/mlhang/latest'));
|
||||
// PlayStation Store
|
||||
router.get('/ps/list/:gridName', require('./routes/ps/list'));
|
||||
|
||||
// Nintendo
|
||||
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('/who/news-room/:type', require('./routes/who/news-room'));
|
||||
|
||||
|
||||
26
lib/routes/nintendo/eshop_hk.js
Normal file
26
lib/routes/nintendo/eshop_hk.js
Normal file
@@ -0,0 +1,26 @@
|
||||
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/switch_software.json`,
|
||||
});
|
||||
const data = response.data.slice(0, 9);
|
||||
|
||||
// 获取游戏描述
|
||||
const result = await util.ProcessItem(data, ctx.cache);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Nintendo eShop (港服) 新游戏`,
|
||||
link: `https://www.nintendo.com.hk/software/switch/index.html`,
|
||||
description: `Nintendo eShop (港服) 新上架的游戏`,
|
||||
item: result.map((item) => ({
|
||||
title: item.title,
|
||||
description: `<img referrerpolicy="no-referrer" src="https://www.nintendo.com.hk/software/img/bnr/${item.thumb_img}"><br><strong>发售日期:</strong>${item.release_date}<br><strong>价格:</strong>${
|
||||
item.price
|
||||
}港币<br><strong>支持中文:</strong>${item.lang === 'CN' ? '是' : '否'}<br><strong>发行商:</strong>${item.maker_publisher}<br>${item.content}`,
|
||||
link: item.link,
|
||||
})),
|
||||
};
|
||||
};
|
||||
20
lib/routes/nintendo/eshop_jp.js
Normal file
20
lib/routes/nintendo/eshop_jp.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const axios = require('../../utils/axios');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: `https://search.nintendo.jp/nintendo_soft/search.json?opt_sshow=1&fq=ssitu_s%3Aonsale%20OR%20ssitu_s%3Apreorder%20OR%20memo_bg%3Aforced&limit=24&page=1&c=50310840317994813&opt_osale=1&opt_hard=1_HAC&sort=sodate%20desc%2Cscore`,
|
||||
});
|
||||
const data = response.data.result.items.slice(0, 9);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Nintendo eShop (日服) 新游戏`,
|
||||
link: `https://www.nintendo.co.jp/software/switch/index.html`,
|
||||
description: `Nintendo eShop (日服) 新上架的游戏`,
|
||||
item: data.map((item) => ({
|
||||
title: item.title,
|
||||
description: `<img referrerpolicy="no-referrer" src="https://img-eshop.cdn.nintendo.net/i/${item.iurl}.jpg"><br><strong>发售日期:</strong>${item.pdate}<br><strong>价格:</strong>${item.dprice}円`,
|
||||
link: `https://ec.nintendo.com/JP/ja/titles/${item.id}`,
|
||||
})),
|
||||
};
|
||||
};
|
||||
41
lib/routes/nintendo/eshop_us.js
Normal file
41
lib/routes/nintendo/eshop_us.js
Normal file
@@ -0,0 +1,41 @@
|
||||
const axios = require('../../utils/axios');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await axios({
|
||||
method: 'post',
|
||||
url: `https://u3b6gr4ua3-dsn.algolia.net/1/indexes/*/queries?x-algolia-agent=Algolia%20for%20vanilla%20JavaScript%20(lite)%203.22.1%3BJS%20Helper%202.20.1&x-algolia-application-id=U3B6GR4UA3&x-algolia-api-key=9a20c93440cf63cf1a7008d75f7438bf`,
|
||||
data: {
|
||||
requests: [
|
||||
{
|
||||
indexName: 'noa_aem_game_en_us_release_des',
|
||||
params:
|
||||
'query=&hitsPerPage=42&maxValuesPerFacet=30&page=0&facets=%5B%22generalFilters%22%2C%22platform%22%2C%22availability%22%2C%22categories%22%2C%22filterShops%22%2C%22virtualConsole%22%2C%22characters%22%2C%22priceRange%22%2C%22esrb%22%2C%22filterPlayers%22%5D&tagFilters=&facetFilters=%5B%5B%22availability%3ANew%20releases%22%5D%2C%5B%22platform%3ANintendo%20Switch%22%5D%5D',
|
||||
},
|
||||
{
|
||||
indexName: 'noa_aem_game_en_us_release_des',
|
||||
params:
|
||||
'query=&hitsPerPage=1&maxValuesPerFacet=30&page=0&attributesToRetrieve=%5B%5D&attributesToHighlight=%5B%5D&attributesToSnippet=%5B%5D&tagFilters=&facets=availability&facetFilters=%5B%5B%22platform%3ANintendo%20Switch%22%5D%5D',
|
||||
},
|
||||
{
|
||||
indexName: 'noa_aem_game_en_us_release_des',
|
||||
params:
|
||||
'query=&hitsPerPage=1&maxValuesPerFacet=30&page=0&attributesToRetrieve=%5B%5D&attributesToHighlight=%5B%5D&attributesToSnippet=%5B%5D&tagFilters=&facets=platform&facetFilters=%5B%5B%22availability%3ANew%20releases%22%5D%5D',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
const data = response.data.results[0].hits.slice(0, 9);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Nintendo eShop (美服) 新游戏`,
|
||||
link: `https://www.nintendo.com/games/`,
|
||||
description: `Nintendo eShop (美服) 新上架的游戏`,
|
||||
item: data.map((item) => ({
|
||||
title: item.title,
|
||||
description: `<img referrerpolicy="no-referrer" src="https://www.nintendo.com${item.boxArt}"><br><strong>发售日期:</strong>${new Date(item.releaseDateMask).toLocaleString()}<br><strong>价格:</strong>$${
|
||||
item.msrp
|
||||
}<br><br>${item.description}`,
|
||||
link: `https://www.nintendo.com${item.url}`,
|
||||
})),
|
||||
};
|
||||
};
|
||||
28
lib/routes/nintendo/utils.js
Normal file
28
lib/routes/nintendo/utils.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
async function load(link) {
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
|
||||
const $ = cheerio.load(data); // 使用 cheerio 加载返回的 HTML
|
||||
const description = $('.description').html();
|
||||
|
||||
return { content: description };
|
||||
}
|
||||
|
||||
const ProcessItem = async (list, caches) =>
|
||||
await Promise.all(
|
||||
list.map(async (item) => {
|
||||
const other = await caches.tryGet(item.link, async () => await load(item.link));
|
||||
return Promise.resolve(Object.assign({}, item, other));
|
||||
})
|
||||
);
|
||||
|
||||
module.exports = {
|
||||
ProcessItem,
|
||||
};
|
||||
Reference in New Issue
Block a user