Skip to content

Commit c92ec54

Browse files
committed
stability improvements
1 parent 04c0af2 commit c92ec54

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

main.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,14 @@ def getWebScrapePresence():
468468
# sleep for 0.2 seconds, this is done after every steam request, to avoid getting perma banned (yes steam is scuffed)
469469
sleep(0.2)
470470

471-
page = requests.post(URL, cookies=cj)
471+
try:
472+
page = requests.post(URL, cookies=cj)
473+
except requests.exceptions.RetryError as e:
474+
log(f"failed connecting to {URL}, perhaps steam is down for maintenance?\n error:{e}")
475+
return
476+
except Exception as e:
477+
error(f"error caught while web scraping data from {URL}, ignoring\n error:{e}")
478+
return
472479

473480
if page.status_code == 403:
474481
error("Forbidden, Access to Steam has been denied, please verify that your cookies are up to date")
@@ -549,7 +556,16 @@ def getSteamPresence():
549556
def getSteamRichPresence():
550557
for i in userID.split(","):
551558
# userID type 3. <id3> = <id64> - 76561197960265728
552-
pageRequest = makeWebRequest(f"https://steamcommunity.com/miniprofile/{int(i) - 76561197960265728}")
559+
URL = f"https://steamcommunity.com/miniprofile/{int(i) - 76561197960265728}"
560+
try:
561+
pageRequest = makeWebRequest(URL)
562+
except requests.exceptions.RetryError as e:
563+
log(f"failed connecting to {URL}, perhaps steam is down for maintenance?\n error:{e}")
564+
return
565+
except Exception as e:
566+
error(f"error caught while fetching enhanced RPC data from {URL}, ignoring\n error:{e}")
567+
return
568+
553569
if pageRequest == "error":
554570
return
555571

@@ -791,7 +807,6 @@ def setPresenceDetails():
791807

792808
try:
793809
RPC.update(
794-
# state field currently unused
795810
details = details, state = state,
796811
start = startTime,
797812
large_image = coverImage, large_text = coverImageText,

0 commit comments

Comments
 (0)