diff --git a/docs/game.md b/docs/game.md index c8d00b0b8..f79343b12 100644 --- a/docs/game.md +++ b/docs/game.md @@ -103,6 +103,12 @@ pageClass: routes +## GameApps.hk 香港手机游戏网 + +### 最新消息 + + + ## GameRes 游资网 ### 热点推荐 diff --git a/lib/v2/gameapps/index.js b/lib/v2/gameapps/index.js new file mode 100644 index 000000000..89c0cedfd --- /dev/null +++ b/lib/v2/gameapps/index.js @@ -0,0 +1,56 @@ +const got = require('@/utils/got'); +const parser = require('@/utils/rss-parser'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const baseUrl = 'https://www.gameapps.hk'; + const feed = await parser.parseURL(`https://www.gameapps.hk/rss`); + + const items = await Promise.all( + feed.items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const response = await got({ + url: item.link, + headers: { + Referer: baseUrl, + }, + }); + const $ = cheerio.load(response.data); + + // remove unwanted key value + delete item.content; + delete item.contentSnippet; + delete item.isoDate; + + item.description = art(path.join(__dirname, 'templates/description.art'), { + src: $('div.introduction.media.news-intro div.media-left').find('img').attr('src'), + intro: $('div.introduction.media.news-intro div.media-body').html().trim(), + desc: $('.news-content').html().trim(), + }); + item.guid = item.guid.substring(0, item.link.lastIndexOf('/')); + item.pubDate = parseDate(item.pubDate); + + return item; + }) + ) + ); + + ctx.state.data = { + title: feed.title, + link: feed.link, + description: feed.description, + item: items, + language: feed.language, + }; + + ctx.state.json = { + title: feed.title, + link: feed.link, + description: feed.description, + item: items, + language: feed.language, + }; +}; diff --git a/lib/v2/gameapps/maintainer.js b/lib/v2/gameapps/maintainer.js new file mode 100644 index 000000000..83fc5ed48 --- /dev/null +++ b/lib/v2/gameapps/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['TonyRL'], +}; diff --git a/lib/v2/gameapps/radar.js b/lib/v2/gameapps/radar.js new file mode 100644 index 000000000..83c725e32 --- /dev/null +++ b/lib/v2/gameapps/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'gameapps.hk': { + _name: 'GameApps.hk 香港手机游戏网', + '.': [ + { + title: '最新消息', + docs: 'https://docs.rsshub.app/game.html#gameapps-hk-xiang-gang-shou-ji-you-xi-wang', + source: ['/'], + target: '/gameapps', + }, + ], + }, +}; diff --git a/lib/v2/gameapps/router.js b/lib/v2/gameapps/router.js new file mode 100644 index 000000000..20c52b09d --- /dev/null +++ b/lib/v2/gameapps/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/', require('./index')); +}; diff --git a/lib/v2/gameapps/templates/description.art b/lib/v2/gameapps/templates/description.art new file mode 100644 index 000000000..d41376f7f --- /dev/null +++ b/lib/v2/gameapps/templates/description.art @@ -0,0 +1,3 @@ +
+{{@ intro }} +{{@ desc }}