diff options
author | André Glüpker <git@wgmd.de> | 2018-01-06 21:18:09 +0100 |
---|---|---|
committer | André Glüpker <git@wgmd.de> | 2018-01-06 21:18:09 +0100 |
commit | fd3e38f818d1cf29fb71820afa0a65e61a875a20 (patch) | |
tree | c62afebf8f39d9dbfa4287e3f16f5f1a483cbf04 /SteamAPI.py | |
parent | c9bad924c7c3bc91cdf220fbc1507d1812d504f3 (diff) | |
download | steam-fd3e38f818d1cf29fb71820afa0a65e61a875a20.tar.gz steam-fd3e38f818d1cf29fb71820afa0a65e61a875a20.tar.bz2 steam-fd3e38f818d1cf29fb71820afa0a65e61a875a20.zip |
Remove gameextrainfo
Steam API does not provide this anymore.
We now fetch the gamelist ourself and use gameid.
Diffstat (limited to 'SteamAPI.py')
-rw-r--r-- | SteamAPI.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/SteamAPI.py b/SteamAPI.py index 580b375..cc67f20 100644 --- a/SteamAPI.py +++ b/SteamAPI.py @@ -19,6 +19,36 @@ class SteamAPI(): def __init__(self, token): self.token = token + def getGames(self): + """Get list of steam games by app id. + + Returns: + dict() with str(appid) as keys, str gamename as value + """ + if CACHE: + cache = Caching.readCache('general', 'gamelist', 7*24*60*60) + if cache: + return json.loads(cache) + + url = 'https://api.steampowered.com/ISteamApps/GetAppList/v2' + try: + response = urlopen(url) + data = response.read().decode('utf-8') + jsondata = json.loads(data) + applist = jsondata['applist']['apps'] + except KeyError: + return None + except HTTPError: + return None + + gamelist = dict() + for app in applist: + gamelist[int(app['appid'])] = app['name'] + + if CACHE: + cache = Caching.writeCache('general', 'gamelist', json.dumps(gamelist)) + return gamelist + def getProfiles(self, steamids): """Get steam profiles. @@ -140,7 +170,7 @@ class SteamAPI(): print('No game in json:', jsondata) return None - def getGames(self, steamid): + def getPlayerGames(self, steamid): """Fetch a list of games a person possesses. Args: |