feat(route): add jump app游戏打折 (#8257)

Co-authored-by: Tony <TonyRL@users.noreply.github.com>
This commit is contained in:
zytomorrow
2021-09-26 02:10:55 -07:00
committed by GitHub
co-authored by Tony
parent aecd6f5fec
commit c4afbb66f9
6 changed files with 273 additions and 0 deletions
+23
View File
@@ -157,6 +157,29 @@ pageClass: routes
<Route author="GensouSakuya kt286" example="/indienova/article" path="indienova/:type" :paramsDesc="['类型: `article` 文章,`development` 开发']"/>
## JUMP
### 游戏折扣
<Route author="zytomorrow" path="/jump/discount/:platform/:filter?/:countries?" example="/jump/discount/ps5/all" :paramsDesc="['平台:switch,ps4,ps5,xbox,steam,epic', '过滤参数,all-全部,jx-精选,sd-史低,dl-独立,vip-会员', '地区,具体支持较多,可自信查看地区简写']">
| switch | ps4 | ps5 | xbox | steam | epic |
| ------ | --- | ---- | ---- | ---- | ---- |
| 可用 | 可用 | 可用 | 不可用 | 可用 | 不可用 |
| filter | switch | ps4 | ps5 | steam |
| ------ | ------ | --- | --- | ----- |
| all | ✔ | ✔ | ✔ | ✔ |
| jx | ✔ | ✔ | ❌ | ✔ |
| sd | ✔ | ✔ | ✔ | ✔ |
| dl | ❌ | ✔ | ❌ | ✔ |
| vip | ❌ | ❌ | ✔ | ❌ |
| 北美 | 欧洲(英语) | 法国 | 德国 | 日本 |
| ---- | ------------ | ---- | ---- | ---- |
| na | eu | fr | de | jp |
</Route>
## Konami
### PES Mobile 公告
+120
View File
@@ -0,0 +1,120 @@
const got = require('@/utils/got');
const { art } = require('@/utils/render');
const path = require('path');
const discountUrl = 'https://switch.jumpvg.com/jump/discount/find4Discount/5/v2';
// const detailUrl = 'https://switch.jumpvg.com/jump/game/detail';
// 平台对应参数
const platformObject = {
switch: 1,
steam: 4,
ps4: 51,
ps5: 52,
};
// 各个平台分类参数
const filterObject = {
switch: {
jx: 16,
all: 17,
sd: 18,
},
steam: {
jx: 26,
all: 27,
dl: 28,
sd: 29,
},
ps4: {
jx: 19,
all: 20,
sd: 21,
vip: 22,
},
ps5: {
all: 23,
sd: 24,
vip: 25,
},
};
// 分类对应名
const filterName = {
jx: '精选',
sd: '史低',
all: '全部',
vip: '会员',
dl: '独立',
};
const getDiscountNum = async (platform) => {
const response = await got.get(`https://switch.jumpvg.com/jump/platform/order/v2?needCount=1&needFilter=1&version=3`);
const data = response.data.data;
let totalNum = 0;
for (const index in data) {
if (data[index].platformAlias.toLocaleLowerCase() === platform.toLocaleLowerCase()) {
totalNum = data[index].gameNum;
break;
}
}
return totalNum;
};
const getSinglePageDiscountItem = async (countries, offset, platform, termsId) => {
const response = await got.get(`${discountUrl}?countries=${countries}&offset=${offset}&platform=${platform}&size=10&termsId=${termsId}&version=3`);
return response.data.data;
};
// 防止触发反爬
const getAllPageDiscountItem = async (countries, platform, termsId, totalNum) => {
let allDiscountItem = [];
for (let idx = 0; idx <= Math.round(totalNum / 10); idx++) {
// eslint-disable-next-line no-await-in-loop
const itemList = await getSinglePageDiscountItem(countries, idx * 10, platform, termsId);
allDiscountItem = allDiscountItem.concat(itemList);
}
return allDiscountItem;
};
// const getGameDetail = (item, caches) => caches.tryGet(`${item.platform}-${item.oldGameId}`, async () => {
// const response = await got.get(`${detailUrl}?clickFrom=-1&id=${item.oldGameId}&platform=${item.platform}&version=3`);
// return response.data.data;
// });
// 依次获取详情
// const seqGetGameDetail = async (allDiscountItem, ctx) => {
// for (const idx in allDiscountItem) {
// logger.info(idx);
// // eslint-disable-next-line no-await-in-loop
// const detail = await getGameDetail(allDiscountItem[idx], ctx.cache);
// allDiscountItem[idx].detail = detail;
// logger.info(detail);
// };
// };
module.exports = async (ctx) => {
const platform = ctx.params.platform;
const filter = ctx.params.filter || 'all';
const countries = ctx.params.countries || '';
const discountNum = await getDiscountNum(platform);
const allDiscountItem = await getAllPageDiscountItem(countries, platformObject[platform.toLocaleLowerCase()], filterObject[platform.toLocaleLowerCase()][filter], discountNum);
// 并发极易触发反爬,此处可选是否获取detail,detail也只能顺序获取--反爬严格,放弃
// if (needDeatail) {
// await seqGetGameDetail(allDiscountItem, ctx);
// }
ctx.state.data = {
title: `jump 折扣-${platform}-${filterName[filter]}${countries ? `-${countries}` : ''}`,
link: 'https://jumpvg.com/',
description: 'jump 发现游戏',
item: allDiscountItem.map((item) => ({
title: `${item.name}-${item.cutOff}%-¥${item.price}`,
description: art(path.resolve(__dirname, './templates/discount.art'), { item }),
link: item.banner,
guid: `${platform}-${item.oldGameId}-${item.cutOff}`, // 平台-打折id-打折率
})),
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/discount/:platform/:filter?/:countries?': ['zytomorrow'],
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'jumpvg.com': {
_name: 'jump app',
switch: [
{
title: '折扣清单',
docs: 'https://docs.rsshub.app/game.html#jump',
source: ['/'],
target: '/jump/discount/switch',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/discount/:platform/:filter?/:countries?', require('./discount.js'));
};
+111
View File
@@ -0,0 +1,111 @@
<div>
<img src="{{item.banner}}"/>
<table style="font-family: verdana,arial,sans-serif;font-size:11px;color:#333333;border-width: 1px;border-color: #999999;border-collapse: collapse;">
<tr style="background-color:#d4e3e5;">
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
名称
</td>
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
{{item.name}}
</td>
</tr>
{{if item.subName}}
<tr style="background-color:#d4e3e5;">
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
别名
</td>
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
{{item.subName}}
</td>
</tr>
{{/if}}
<tr style="background-color:#d4e3e5;">
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
中文支持
</td>
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
{{item.chinese}}
</td>
</tr>
{{if item.lowestPriceCountry}}
<tr style="background-color:#d4e3e5;">
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
史低地区
</td>
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
{{item.lowestPriceCountry}}
</td>
</tr>
{{/if}}
{{if item.isLowest}}
<tr style="background-color:#d4e3e5;">
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
史低
</td>
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
是
</td>
</tr>
{{else}}
<tr style="background-color:#d4e3e5;">
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
史低
</td>
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
否
</td>
</tr>
{{/if}}
{{if item.pubDate}}
<tr style="background-color:#d4e3e5;">
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
发布日期
</td>
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
{{item.pubDate}}
</td>
</tr>
{{/if}}
<tr style="background-color:#d4e3e5;">
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
当前价格
</td>
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
¥{{item.price}}
</td>
</tr>
<tr style="background-color:#d4e3e5;">
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
原价
</td>
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
¥{{item.originPrice}}
</td>
</tr>
<tr style="background-color:#d4e3e5;">
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
折扣地区
</td>
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
{{item.priceCountry}}
</td>
</tr>
<tr style="background-color:#d4e3e5;">
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
折扣
</td>
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
{{item.cutOff}}%
</td>
</tr>
{{if item.mcScore}}
<tr style="background-color:#d4e3e5;">
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
metacritic评分
</td>
<td style=" border-width: 1px;padding: 8px;border-style: solid;border-color: #a9c6c9;">
{{item.mcScore}}
</td>
</tr>
{{/if}}
</div>