feat(source): add steam

This commit is contained in:
ourongxing
2025-10-27 16:58:16 +00:00
parent 8142074b3c
commit 3721fd383a
6 changed files with 52 additions and 1 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

+1
View File
@@ -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')
+32
View File
@@ -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
})
+2 -1
View File
@@ -42,5 +42,6 @@
"ifeng": "fenghuangwang-redianzixun",
"chongbuluo-latest": "chongbuluo-zuixin",
"chongbuluo-hot": "chongbuluo-zuire",
"douban": "douban-remendianying"
"douban": "douban-remendianying",
"steam": "Steam-zaixianrenshu"
}
+8
View File
@@ -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<string, OriginSource>
export function genSources() {
+9
View File
@@ -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
}
}