added support for non top200 permanent games

This commit is contained in:
2019-07-19 10:17:20 +02:00
parent 12c02eed22
commit 4e4b3889d4
3 changed files with 49 additions and 29 deletions

32
tools/SteamApps.py Normal file
View File

@@ -0,0 +1,32 @@
import requests
class SteamApps:
__instance = None
@staticmethod
def get_instance():
""" Static access method. """
if not SteamApps.__instance:
SteamApps()
return SteamApps.__instance
def __init__(self):
""" Virtually private constructor. """
if SteamApps.__instance:
raise Exception("This class is a singleton!")
else:
SteamApps.__instance = self
# Load steam appid <-> game list
r = requests.get("http://api.steampowered.com/ISteamApps/GetAppList/v0002/?format=json")
if r.status_code == 200:
self.glist = r.json()
else:
self.glist = None
def appid2game(self, appid):
for game in self.glist["applist"]["apps"]:
if appid == game["appid"]:
return game