feat: add rockstar games social club events (#4221)
This commit is contained in:
@@ -161,6 +161,19 @@ pageClass: routes
|
||||
|
||||
<Route author="LightStrawberry" example="/psnine/game" path="/psnine/game"/>
|
||||
|
||||
## Rockstar Games Social Club
|
||||
|
||||
### 在线活动
|
||||
|
||||
<Route author="kookxiang" example="/socialclub/events/GTAV" path="/socialclub/events/:game?" :paramsDesc="['游戏代码(默认所有)']">
|
||||
|
||||
| 游戏代码 | 游戏名称 |
|
||||
| -------- | ------------ |
|
||||
| GTAV | 侠盗猎车手 5 |
|
||||
| RDR2 | 荒野大镖客 2 |
|
||||
|
||||
</Route>
|
||||
|
||||
## Steam
|
||||
|
||||
### Steam search
|
||||
|
||||
@@ -2360,6 +2360,9 @@ router.get('/moxingfans', require('./routes/moxingfans'));
|
||||
// Chiphell
|
||||
router.get('/chiphell/forum/:forumId?', require('./routes/chiphell/forum'));
|
||||
|
||||
// Rockstar Games Social Club
|
||||
router.get('/socialclub/events/:game?', require('./routes/socialclub/events'));
|
||||
|
||||
// 湖北大学
|
||||
router.get('/hubu/news/:type', require('./routes/universities/hubu/news'));
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
const gameList = ['GTAV', 'RDR2'];
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const gameId = gameList.includes(ctx.params.game) ? ctx.params.game : '';
|
||||
const baseUrl = `https://zh.socialclub.rockstargames.com/events/eventlisting?pageId=1&gameId=${gameId}`;
|
||||
// R星的傻逼防爬
|
||||
const browser = await require('@/utils/puppeteer')();
|
||||
const page = await browser.newPage();
|
||||
await page.goto(baseUrl + '&_=' + Date.now());
|
||||
// eslint-disable-next-line
|
||||
const jsonStr = await page.evaluate(() => document.body.innerText);
|
||||
browser.close();
|
||||
|
||||
const { events } = JSON.parse(jsonStr);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Online Events - Rockstar Games Social Club',
|
||||
link: 'https://zh.socialclub.rockstargames.com/events?gameId=' + gameId,
|
||||
item:
|
||||
events &&
|
||||
events.map((x) => ({
|
||||
title: x.headerText,
|
||||
category: x.eventType,
|
||||
description: (x.imgUrl ? `<img src="${x.imgUrl}" /><br>` : '') + x.description,
|
||||
pubDate: new Date(x.startDate).getTime() / 1000,
|
||||
link: `https://zh.socialclub.rockstargames.com/events/${x.urlHash}/${x.slug}/1`,
|
||||
})),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user