added support for non top200 permanent games
This commit is contained in:
32
tools/SteamApps.py
Normal file
32
tools/SteamApps.py
Normal 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
|
||||
Reference in New Issue
Block a user