Skip to content

Commit 3721fd3

Browse files
committed
feat(source): add steam
1 parent 8142074 commit 3721fd3

6 files changed

Lines changed: 52 additions & 1 deletion

File tree

public/icons/steam.png

37.7 KB
Loading

server/glob.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ declare module 'glob:./sources/{*.ts,**/index.ts}' {
3131
export const solidot: typeof import('./sources/solidot')
3232
export const sputniknewscn: typeof import('./sources/sputniknewscn')
3333
export const sspai: typeof import('./sources/sspai')
34+
export const steam: typeof import('./sources/steam')
3435
export const thepaper: typeof import('./sources/thepaper')
3536
export const tieba: typeof import('./sources/tieba')
3637
export const toutiao: typeof import('./sources/toutiao')

server/sources/steam.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import * as cheerio from "cheerio"
2+
import type { NewsItem } from "@shared/types"
3+
4+
export default defineSource(async () => {
5+
const response: any = await myFetch("https://store.steampowered.com/stats/stats/")
6+
const $ = cheerio.load(response)
7+
const $rows = $("#detailStats tr.player_count_row")
8+
const news: NewsItem[] = []
9+
10+
$rows.each((_, el) => {
11+
const $el = $(el)
12+
const $a = $el.find("a.gameLink")
13+
const url = $a.attr("href")
14+
const gameName = $a.text().trim()
15+
const currentPlayers = $el.find("td:first-child .currentServers").text().trim()
16+
17+
if (url && gameName && currentPlayers) {
18+
const title = gameName
19+
news.push({
20+
url,
21+
title,
22+
id: url,
23+
pubDate: Date.now(),
24+
extra: {
25+
info: currentPlayers,
26+
},
27+
})
28+
}
29+
})
30+
31+
return news
32+
})

shared/pinyin.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@
4242
"ifeng": "fenghuangwang-redianzixun",
4343
"chongbuluo-latest": "chongbuluo-zuixin",
4444
"chongbuluo-hot": "chongbuluo-zuire",
45-
"douban": "douban-remendianying"
45+
"douban": "douban-remendianying",
46+
"steam": "Steam-zaixianrenshu"
4647
}

shared/pre-sources.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,14 @@ export const originSources = {
421421
type: "hottest",
422422
home: "https://www.douban.com",
423423
},
424+
"steam": {
425+
name: "Steam",
426+
column: "world",
427+
title: "在线人数",
428+
color: "blue",
429+
type: "hottest",
430+
home: "https://store.steampowered.com",
431+
},
424432
} as const satisfies Record<string, OriginSource>
425433

426434
export function genSources() {

shared/sources.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,5 +481,14 @@
481481
"home": "https://www.douban.com",
482482
"color": "green",
483483
"interval": 600000
484+
},
485+
"steam": {
486+
"title": "在线人数",
487+
"name": "Steam",
488+
"type": "hottest",
489+
"column": "world",
490+
"home": "https://store.steampowered.com",
491+
"color": "blue",
492+
"interval": 600000
484493
}
485494
}

0 commit comments

Comments
 (0)