diff --git a/docs/en/game.md b/docs/en/game.md index 440faf119..6790939bc 100755 --- a/docs/en/game.md +++ b/docs/en/game.md @@ -62,6 +62,40 @@ Language codes +## Gamer Secret + +### Latest News + + + +### Category + + + +| Latest News | PC | Playstation | Nintendo | Xbox | Moblie | +| ----------- | -- | ----------- | -------- | ---- | ------ | +| latest-news | pc | playstation | nintendo | xbox | moblie | + +Or + +| GENERAL | GENERAL EN | MOBILE | MOBILE EN | +| ---------------- | ------------------ | --------------- | ----------------- | +| category/general | category/generalen | category/mobile | category/mobileen | + +| NINTENDO | NINTENDO EN | PC | PC EN | +| ----------------- | ------------------- | ----------- | ------------- | +| category/nintendo | category/nintendoen | category/pc | category/pcen | + +| PLAYSTATION | PLAYSTATION EN | REVIEWS | +| -------------------- | ---------------------- | ---------------- | +| category/playstation | category/playstationen | category/reviews | + +| XBOX | XBOX EN | +| ------------- | --------------- | +| category/xbox | category/xboxen | + + + ## Konami ### PES Mobile Announcement diff --git a/docs/game.md b/docs/game.md index ab5f3e202..503472d29 100644 --- a/docs/game.md +++ b/docs/game.md @@ -151,6 +151,40 @@ pageClass: routes +## Gamer Secret + +### 最新資訊 + + + +### 分類 + + + +| Latest News | PC | Playstation | Nintendo | Xbox | Moblie | +| ----------- | -- | ----------- | -------- | ---- | ------ | +| latest-news | pc | playstation | nintendo | xbox | moblie | + +或者 + +| GENERAL | GENERAL EN | MOBILE | MOBILE EN | +| ---------------- | ------------------ | --------------- | ----------------- | +| category/general | category/generalen | category/mobile | category/mobileen | + +| NINTENDO | NINTENDO EN | PC | PC EN | +| ----------------- | ------------------- | ----------- | ------------- | +| category/nintendo | category/nintendoen | category/pc | category/pcen | + +| PLAYSTATION | PLAYSTATION EN | REVIEWS | +| -------------------- | ---------------------- | ---------------- | +| category/playstation | category/playstationen | category/reviews | + +| XBOX | XBOX EN | +| ------------- | --------------- | +| category/xbox | category/xboxen | + + + ## GNN.tw 游戏新闻 ### GNN.tw 游戏新闻 diff --git a/lib/v2/gamersecret/index.js b/lib/v2/gamersecret/index.js new file mode 100644 index 000000000..5bebc0cd8 --- /dev/null +++ b/lib/v2/gamersecret/index.js @@ -0,0 +1,60 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const type = ctx.params.type ?? 'latest-news'; + const category = ctx.params.category ?? ''; + + const rootUrl = 'https://www.gamersecret.com'; + const currentUrl = `${rootUrl}/${type}${category ? `/${category}` : ''}`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + let items = $('.jeg_post_title a') + .slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 20) + .toArray() + .map((item) => { + item = $(item); + + return { + title: item.text(), + link: item.attr('href'), + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + content('img').each(function () { + content(this).attr('src', content(this).attr('data-src')); + }); + + item.author = content('.jeg_meta_author').text().replace(/by/, ''); + item.pubDate = timezone(parseDate(detailResponse.data.match(/datePublished":"(.*)","dateModified/)[1]), +8); + item.description = content('.thumbnail-container').html() + content('.elementor-text-editor, .content-inner').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/gamersecret/maintainer.js b/lib/v2/gamersecret/maintainer.js new file mode 100644 index 000000000..962c750d6 --- /dev/null +++ b/lib/v2/gamersecret/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:type?/:category?': ['nczitzk'], +}; diff --git a/lib/v2/gamersecret/radar.js b/lib/v2/gamersecret/radar.js new file mode 100644 index 000000000..9b60c79eb --- /dev/null +++ b/lib/v2/gamersecret/radar.js @@ -0,0 +1,31 @@ +module.exports = { + 'gamersecret.com': { + _name: 'Gamer Secret', + '.': [ + { + title: '最新資訊', + docs: 'https://docs.rsshub.app/game.html#gamer-secret-zui-xin-zi-xun', + source: ['/:type', '/:type/:category', '/'], + target: '/gamersecret', + }, + { + title: '分類', + docs: 'https://docs.rsshub.app/game.html#gamer-secret-fen-lei', + source: ['/:type', '/:type/:category', '/'], + target: '/gamersecret/:type?/:category?', + }, + { + title: 'Latest News', + docs: 'https://docs.rsshub.app/game.html#gamer-secret-latest-news', + source: ['/:type', '/:type/:category', '/'], + target: '/gamersecret', + }, + { + title: 'Category', + docs: 'https://docs.rsshub.app/game.html#gamer-secret-category', + source: ['/:type', '/:type/:category', '/'], + target: '/gamersecret/:type?/:category?', + }, + ], + }, +}; diff --git a/lib/v2/gamersecret/router.js b/lib/v2/gamersecret/router.js new file mode 100644 index 000000000..f6aadf778 --- /dev/null +++ b/lib/v2/gamersecret/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:type?/:category?', require('./index')); +};