diff --git a/docs/game.md b/docs/game.md index 23224e01b..de115e240 100644 --- a/docs/game.md +++ b/docs/game.md @@ -669,11 +669,11 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547` ### 游戏折扣 - + | Steam 最新折扣 | Steam 热门游戏折扣 | Steam 热门中文游戏折扣 | Steam 历史低价 | Steam 中文游戏历史低价 | | -------------- | ------------------ | ---------------------- | -------------- | ---------------------- | -| new | hot | hot_chinese | low | low_chinese | +| discount | popular | popular_cn | low | low_cn | diff --git a/lib/router.js b/lib/router.js index d1c4d8e51..6280249c3 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1774,7 +1774,7 @@ router.get('/gov/veterans/hebei/:type', lazyloadRouteHandler('./routes/gov/veter router.get('/dilbert/strip', lazyloadRouteHandler('./routes/dilbert/strip')); // 游戏打折情报 -router.get('/yxdzqb/:type', lazyloadRouteHandler('./routes/yxdzqb')); +// router.get('/yxdzqb/:type', lazyloadRouteHandler('./routes/yxdzqb')); // 怪物猎人 router.get('/monsterhunter/update', lazyloadRouteHandler('./routes/mhw/update')); diff --git a/lib/routes/yxdzqb/index.js b/lib/v2/yxdzqb/index.js similarity index 74% rename from lib/routes/yxdzqb/index.js rename to lib/v2/yxdzqb/index.js index e34b69be6..8ce50f7e5 100644 --- a/lib/routes/yxdzqb/index.js +++ b/lib/v2/yxdzqb/index.js @@ -1,6 +1,7 @@ const got = require('@/utils/got'); -const url = require('url'); const cheerio = require('cheerio'); +const { art } = require('@/utils/render'); +const path = require('path'); const host = 'https://www.yxdzqb.com'; @@ -15,7 +16,7 @@ const map = { module.exports = async (ctx) => { const type = ctx.params.type; - const link = url.resolve(host, map[type]); + const link = `${host}/${map.hasOwnProperty(type) ? map[type] : `index_${type}.html`}`; const response = await got.get(link); const $ = cheerio.load(response.data); @@ -27,7 +28,10 @@ module.exports = async (ctx) => { item = $(item); const title = item.find('div table:nth-child(1) tr td:nth-child(1)').text(); - const description = ` tbody > tr > td:nth-child(1) > img').attr('src')}>` + item.find('div.collapse').html(); + const description = art(path.join(__dirname, 'templates/description.art'), { + src: item.find('table.cell_tabs > tbody > tr > td:nth-child(1) > img').attr('src'), + description: item.find('div.collapse').html(), + }); const link = item.find('div.collapse table.cell_tabs > tbody > tr > td:nth-child(1) > a').attr('href'); const guid = link + item.find('div.cell_price span:nth-child(2)').text(); diff --git a/lib/v2/yxdzqb/maintainer.js b/lib/v2/yxdzqb/maintainer.js new file mode 100644 index 000000000..37f650af6 --- /dev/null +++ b/lib/v2/yxdzqb/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:type': ['LogicJake', 'nczitzk'], +}; diff --git a/lib/v2/yxdzqb/radar.js b/lib/v2/yxdzqb/radar.js new file mode 100644 index 000000000..6cb2c9f2a --- /dev/null +++ b/lib/v2/yxdzqb/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'yxdzqb.com': { + _name: '游戏打折情报', + '.': [ + { + title: '游戏折扣', + docs: 'https://docs.rsshub.app/game.html#you-xi-da-zhe-qing-bao-you-xi-zhe-kou', + source: '/', + target: '/yxdzqb/:type', + }, + ], + }, +}; diff --git a/lib/v2/yxdzqb/router.js b/lib/v2/yxdzqb/router.js new file mode 100644 index 000000000..7170a4c83 --- /dev/null +++ b/lib/v2/yxdzqb/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:type', require('./index')); +}; diff --git a/lib/v2/yxdzqb/templates/description.art b/lib/v2/yxdzqb/templates/description.art new file mode 100644 index 000000000..57c5348e2 --- /dev/null +++ b/lib/v2/yxdzqb/templates/description.art @@ -0,0 +1,2 @@ + +{{@ description }} \ No newline at end of file