diff --git a/docs/game.md b/docs/game.md index 2493407a8..15aa82ea6 100644 --- a/docs/game.md +++ b/docs/game.md @@ -157,6 +157,29 @@ pageClass: routes +## JUMP + +### 游戏折扣 + + +| switch | ps4 | ps5 | xbox | steam | epic | +| ------ | --- | ---- | ---- | ---- | ---- | +| 可用 | 可用 | 可用 | 不可用 | 可用 | 不可用 | + +| filter | switch | ps4 | ps5 | steam | +| ------ | ------ | --- | --- | ----- | +| all | ✔ | ✔ | ✔ | ✔ | +| jx | ✔ | ✔ | ❌ | ✔ | +| sd | ✔ | ✔ | ✔ | ✔ | +| dl | ❌ | ✔ | ❌ | ✔ | +| vip | ❌ | ❌ | ✔ | ❌ | + +| 北美 | 欧洲(英语) | 法国 | 德国 | 日本 | +| ---- | ------------ | ---- | ---- | ---- | +| na | eu | fr | de | jp | + + + ## Konami ### PES Mobile 公告 diff --git a/lib/v2/jump/discount.js b/lib/v2/jump/discount.js new file mode 100644 index 000000000..4078a71ad --- /dev/null +++ b/lib/v2/jump/discount.js @@ -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-打折率 + })), + }; +}; diff --git a/lib/v2/jump/maintainer.js b/lib/v2/jump/maintainer.js new file mode 100644 index 000000000..03e48296c --- /dev/null +++ b/lib/v2/jump/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/discount/:platform/:filter?/:countries?': ['zytomorrow'], +}; diff --git a/lib/v2/jump/radar.js b/lib/v2/jump/radar.js new file mode 100644 index 000000000..08a6dbf98 --- /dev/null +++ b/lib/v2/jump/radar.js @@ -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', + }, + ], + }, +}; diff --git a/lib/v2/jump/router.js b/lib/v2/jump/router.js new file mode 100644 index 000000000..42de49b9f --- /dev/null +++ b/lib/v2/jump/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/discount/:platform/:filter?/:countries?', require('./discount.js')); +}; diff --git a/lib/v2/jump/templates/discount.art b/lib/v2/jump/templates/discount.art new file mode 100644 index 000000000..919955209 --- /dev/null +++ b/lib/v2/jump/templates/discount.art @@ -0,0 +1,111 @@ +
+ + + + + + +{{if item.subName}} + + + + +{{/if}} + + + + +{{if item.lowestPriceCountry}} + + + + +{{/if}} +{{if item.isLowest}} + + + + +{{else}} + + + + +{{/if}} +{{if item.pubDate}} + + + + +{{/if}} + + + + + + + + + + + + + + + + +{{if item.mcScore}} + + + + +{{/if}} + \ No newline at end of file
+ 名称 + + {{item.name}} +
+ 别名 + + {{item.subName}} +
+ 中文支持 + + {{item.chinese}} +
+ 史低地区 + + {{item.lowestPriceCountry}} +
+ 史低 + + 是 +
+ 史低 + + 否 +
+ 发布日期 + + {{item.pubDate}} +
+ 当前价格 + + ¥{{item.price}} +
+ 原价 + + ¥{{item.originPrice}} +
+ 折扣地区 + + {{item.priceCountry}} +
+ 折扣 + + {{item.cutOff}}% +
+ metacritic评分 + + {{item.mcScore}} +