Skip to content

Commit d692ea4

Browse files
committed
added secondary game ID, along with a bug fix
1 parent 635c628 commit d692ea4

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,16 @@ create a file named `config.json` in the same directory as this file and fill it
3535
"STEAM_API_KEY": "STEAM_API_KEY",
3636
"USER_ID": "USER_ID",
3737

38-
"DISCORD_APPLICATION_ID": "DISCORD_APPLICATION_ID",
38+
"DISCORD_APPLICATION_ID": "869994714093465680",
3939

4040
"COVER_ART": {
4141
"ENABLED": false,
4242
"STEAM_GRID_API_KEY": "STEAM_GRID_API_KEY"
4343
},
4444

4545
"NON_STEAM_GAMES": {
46-
"ENABLED": false
46+
"ENABLED": false,
47+
"NON_STEAM_DISCORD_APP_ID": "939292559765803018"
4748
},
4849

4950
"CUSTOM_GAME_OVERWRITE": {
@@ -73,9 +74,9 @@ the `USER_ID` is the steam user id of the user you want to track.
7374

7475
**NOTE** this is not the same as the display URL of the user.
7576

76-
the easiest way i've found to get the ID is by throwing your profile url into the steamDB calculator https://steamdb.info/calculator/
77+
the easiest way i've found to get the ID is by throwing your url into the steamDB calculator https://steamdb.info/calculator/
7778

78-
and then taking the ID from that page
79+
and then taking the ID from that url
7980

8081
![ExampleImage](readmeimages/steamDB.png)
8182

@@ -122,6 +123,10 @@ https://chrome.google.com/webstore/detail/get-cookiestxt/bgaddhkoddajcdgocldbbfl
122123

123124
navigate to your profile on steam, and download the cookie file, naming it "cookies.txt" and save it in the same folder as main.py
124125

126+
the NON_STEAM_DISCORD_APP_ID field is a seprate discord app ID which displays when the game isn't found in discord's cached game list, but is being played as a non steam game. The default app id "939292559765803018" is simply called "a game not on steam"
127+
128+
**NOTE** the NON_STEAM_DISCORD_APP_ID and the DISCORD_APPLICATION_ID from earlier in the config file **CANNOT** be the same, because of how this script is coded, they can have the same name but if you want both to be called the same you must create two applications, with the same name
129+
125130
Note: due to the names of non steam games being set by yourself, steam grid DB might have problems finding icons for the game, but if it's in their database, this script will fetch it
126131

127132
# Custom Game Overwrite
@@ -144,8 +149,8 @@ set an URL to the image you want to use, and a text that will appear when hoveri
144149
# Python
145150
python3.8 or higher is required.
146151

147-
run `python3 -m pip install -r requirements.txt` to install all the dependencies
152+
run `pip install -r requirements.txt` to install all the dependencies
148153

149154
then run `python3 main.py`
150155

151-
(these commands should be platform independent, if they're not PLEASE create an issue and inform me)
156+
(these are linux commands, if you're on windows you might need to change them into something, idk search it up)

exampleconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
},
1111

1212
"NON_STEAM_GAMES": {
13-
"ENABLED": false
13+
"ENABLED": false,
14+
"NON_STEAM_DISCORD_APP_ID": "939292559765803018"
1415
},
1516

1617
"CUSTOM_GAME_OVERWRITE": {

main.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ def web_scrape_steam_presence(USER_URL):
8383

8484
for element in soup.find_all("div", class_="profile_in_game_name"):
8585
result = element.text.strip()
86-
87-
return result
86+
87+
# the "last online x min ago" field is the same div as the game name
88+
if "Last Online" not in result:
89+
return result
8890

8991
# looks into the discord api and steals the app IDs from it
9092
def get_game_id(gameName):
@@ -275,6 +277,7 @@ def program():
275277
GRID_KEY = config["COVER_ART"]["STEAM_GRID_API_KEY"]
276278

277279
do_web_scraping = config["NON_STEAM_GAMES"]["ENABLED"]
280+
SECONDARY_APP_ID = config["NON_STEAM_GAMES"]["NON_STEAM_DISCORD_APP_ID"]
278281

279282
do_custom_game = config["CUSTOM_GAME_OVERWRITE"]["ENABLED"]
280283
custom_game_name = config["CUSTOM_GAME_OVERWRITE"]["NAME"]
@@ -366,18 +369,21 @@ def program():
366369
if GRID_ENABLED:
367370
coverImage = get_steam_grid_icon(gameName)
368371

369-
if app_id == DEFAULT_APP_ID:
372+
if app_id == DEFAULT_APP_ID or app_id == SECONDARY_APP_ID:
370373
set_game(do_game_title, gameName, coverImage, startTime, do_custom_state, custom_state, do_custom_icon, custom_icon_url, custom_icon_text)
371374

372375
else:
373376
set_game(do_game_title, None, coverImage, startTime, do_custom_state, custom_state, do_custom_icon, custom_icon_url, custom_icon_text)
374377

375378
# if the game has changed, restart the rich presence client with that new app ID
376-
if oldGameName != gameName and gameName != None:
379+
if (oldGameName != gameName and gameName != None) or (app_id == DEFAULT_APP_ID and scraped == True):
377380
startTime = round(time())
378381
print(f"game changed to \"{gameName}\"")
379382

380383
app_id = get_game_id(gameName)
384+
if app_id == DEFAULT_APP_ID and scraped == True:
385+
app_id = SECONDARY_APP_ID
386+
381387
startTime = round(time())
382388

383389
RPC.close()

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
2-
"name": "steam-presence-on-discord",
3-
"version": "1.3",
2+
"name": "steam-presence",
3+
"version": "1.4.1",
44
"description": "A script which takes the game you're playing on steam and displays it on discord",
55
"author": "JustTemmie",
6-
"repository": "JustTemmie/steam-presence-on-discord",
6+
"repository": "JustTemmie/steam-presence",
77
"license": "MIT",
88
"main": "main.py",
99
"dependencies": {
1010
"python-steamgriddb": ">=1.0.5",
11-
"pypresence": ">=4.2.1"
11+
"pypresence": ">=4.2.1",
12+
"beautifulsoup4": ">=4.7.0"
1213
}
1314
}

0 commit comments

Comments
 (0)