diff --git a/public/icons/steam.png b/public/icons/steam.png new file mode 100644 index 0000000..75ac308 Binary files /dev/null and b/public/icons/steam.png differ diff --git a/server/glob.d.ts b/server/glob.d.ts index e6a8d57..a2bb8bd 100644 --- a/server/glob.d.ts +++ b/server/glob.d.ts @@ -31,6 +31,7 @@ declare module 'glob:./sources/{*.ts,**/index.ts}' { export const solidot: typeof import('./sources/solidot') export const sputniknewscn: typeof import('./sources/sputniknewscn') export const sspai: typeof import('./sources/sspai') + export const steam: typeof import('./sources/steam') export const thepaper: typeof import('./sources/thepaper') export const tieba: typeof import('./sources/tieba') export const toutiao: typeof import('./sources/toutiao') diff --git a/server/sources/steam.ts b/server/sources/steam.ts new file mode 100644 index 0000000..bc8a965 --- /dev/null +++ b/server/sources/steam.ts @@ -0,0 +1,32 @@ +import * as cheerio from "cheerio" +import type { NewsItem } from "@shared/types" + +export default defineSource(async () => { + const response: any = await myFetch("https://store.steampowered.com/stats/stats/") + const $ = cheerio.load(response) + const $rows = $("#detailStats tr.player_count_row") + const news: NewsItem[] = [] + + $rows.each((_, el) => { + const $el = $(el) + const $a = $el.find("a.gameLink") + const url = $a.attr("href") + const gameName = $a.text().trim() + const currentPlayers = $el.find("td:first-child .currentServers").text().trim() + + if (url && gameName && currentPlayers) { + const title = gameName + news.push({ + url, + title, + id: url, + pubDate: Date.now(), + extra: { + info: currentPlayers, + }, + }) + } + }) + + return news +}) diff --git a/shared/pinyin.json b/shared/pinyin.json index b1d2316..e1a7bc0 100644 --- a/shared/pinyin.json +++ b/shared/pinyin.json @@ -42,5 +42,6 @@ "ifeng": "fenghuangwang-redianzixun", "chongbuluo-latest": "chongbuluo-zuixin", "chongbuluo-hot": "chongbuluo-zuire", - "douban": "douban-remendianying" + "douban": "douban-remendianying", + "steam": "Steam-zaixianrenshu" } \ No newline at end of file diff --git a/shared/pre-sources.ts b/shared/pre-sources.ts index 61d55a3..c19f08a 100644 --- a/shared/pre-sources.ts +++ b/shared/pre-sources.ts @@ -421,6 +421,14 @@ export const originSources = { type: "hottest", home: "https://www.douban.com", }, + "steam": { + name: "Steam", + column: "world", + title: "在线人数", + color: "blue", + type: "hottest", + home: "https://store.steampowered.com", + }, } as const satisfies Record export function genSources() { diff --git a/shared/sources.json b/shared/sources.json index 01bb44e..56c360c 100644 --- a/shared/sources.json +++ b/shared/sources.json @@ -481,5 +481,14 @@ "home": "https://www.douban.com", "color": "green", "interval": 600000 + }, + "steam": { + "title": "在线人数", + "name": "Steam", + "type": "hottest", + "column": "world", + "home": "https://store.steampowered.com", + "color": "blue", + "interval": 600000 } } \ No newline at end of file