diff --git a/docs/game.md b/docs/game.md
index dc71f5f11..10dad24e2 100644
--- a/docs/game.md
+++ b/docs/game.md
@@ -315,7 +315,13 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
### Steam news
-
+
+
+| 语言 (Language) | 简体中文 (Simplified Chinese) | 繁體中文 (Traditional Chinese) | 日本語 (Japanese) | 한국어 (Korean) | Български (Bulgarian) | Čeština (Czech) | Dansk (Danish) | Deutsch (German) | Español - España (Spanish - Spain) | Español - Latinoamérica (Spanish - Latin America), | Ελληνικά (Greek) | Français (French) | Italiano (Italian) | Magyar (Hungarian) | Nederlands (Dutch) | Norsk (Norwegian) | Polski (Polish) | Português (Portuguese) | Português - Brasil (Portuguese - Brazil) | Română (Romanian) | Русский (Russian) | Suomi (Finnish) | Svenska (Swedish) | Türkçe (Turkish) | Tiếng Việt (Vietnamese) | Українська (Ukrainian) |
+| --------------- | ----------------------------- | ------------------------------ | ----------------- | --------------- | --------------------- | --------------- | -------------- | ---------------- | ---------------------------------- | -------------------------------------------------- | ---------------- | ----------------- | ------------------ | ------------------ | ------------------ | ----------------- | --------------- | ---------------------- | ---------------------------------------- | ----------------- | ----------------- | --------------- | ----------------- | ---------------- | ----------------------- | ---------------------- |
+| | schinese | tchinese | japanese | koreana | bulgarian | czech | danish | german | spanish | latam | greek | french | italian | hungarian | dutch | norwegian | polish | portuguese | brazilian | romanian | russian | finnish | swedish | turkish | vietnamese | ukrainian |
+
+
## SteamGifts
diff --git a/lib/router.js b/lib/router.js
index 669ffb210..7a3e45a13 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -1216,7 +1216,7 @@ router.get('/huxiu/collection/:id', require('./routes/huxiu/collection'));
// Steam
router.get('/steam/search/:params', require('./routes/steam/search'));
-router.get('/steam/news/:appids', require('./routes/steam/news'));
+router.get('/steam/news/:appid/:language?', require('./routes/steam/news'));
// Steamgifts
router.get('/steamgifts/discussions/:category?', require('./routes/steam/steamgifts/discussions'));
diff --git a/lib/routes/steam/news.js b/lib/routes/steam/news.js
index c139bb94b..9c33b88f9 100644
--- a/lib/routes/steam/news.js
+++ b/lib/routes/steam/news.js
@@ -1,28 +1,45 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
-const queryString = require('query-string');
module.exports = async (ctx) => {
- const { appids } = ctx.params;
- const { data: html } = await got.get(`https://store.steampowered.com/news/`, {
- searchParams: queryString.stringify({ appids }),
+ const { appid, language = 'schinese' } = ctx.params;
+ const response = await got.get(`https://store.steampowered.com/news/app/${appid}`, {
+ headers: {
+ cookie: `Steam_Language=${language}`,
+ },
+ });
+ const $ = cheerio.load(response.data);
+ const { events } = JSON.parse($('#application_config').attr('data-initialevents'));
+
+ const item = events.map((event) => {
+ event.announcement_body.body = event.announcement_body.body
+ .replace(/\[img]\{STEAM_CLAN_IMAGE}/g, '
')
+ .replace(/\[h1]/g, '
')
+ .replace(/\[\/h1]/g, '
')
+ .replace(/\[h2]/g, '')
+ .replace(/\[\/h2]/g, '
')
+ .replace(/\[b]/g, '')
+ .replace(/\[\/b]/g, '')
+ .replace(/\[i]/g, '')
+ .replace(/\[\/i]/g, '')
+ .replace(/\[url=\s?(http.*?)]/g, '')
+ .replace(/\[\/url]/g, '')
+ .replace(/\[list]/g, '')
+ .replace(/\[\/list]/g, '
')
+ .replace(/\[\*]/g, '');
+
+ return {
+ title: event.event_name,
+ link: `https://store.steampowered.com/news/app/${appid}/view/${event.gid}`,
+ pubDate: new Date(event.announcement_body.posttime * 1000),
+ description: event.announcement_body.body,
+ };
});
- const $ = cheerio.load(html);
ctx.state.data = {
- title: $('.pageheader').text(),
- link: `https://store.steampowered.com/news/?appids=${appids}`,
- item: $('#news div[id]')
- .toArray()
- .map((a) => {
- const $el = $(a);
- return {
- title: $el.find('.posttitle').text(),
- link: $el.find('.posttitle a').attr('href'),
- author: $el.find('.feed').text(),
- description: $el.find('.body').html(),
- };
- })
- .filter((it) => it.title),
+ title: $('head title').text(),
+ link: `https://store.steampowered.com/news/app/${appid}`,
+ item,
};
};