diff options
-rw-r--r-- | SteamAPI.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/SteamAPI.py b/SteamAPI.py index 1790989..e6548fc 100644 --- a/SteamAPI.py +++ b/SteamAPI.py @@ -269,6 +269,43 @@ class SteamAPI(): return jsondata return None + def getGameUpdateState(self, gameid, gameversion): + """Fetch the current game update state. + + Args: + gameid: Steam game id + gameversion: Current version of the game + Returns: + dict() with the following keys: + - success Boolean Was able to check version + - up_to_date Boolean If the game is up to date + - version_is_listable Boolean If the game version is listed + - required_version (int) ? New version ? + - message (String) Message to display + """ + + if CACHE: + cache = Caching.readCache('serverupdate', '%s-%s' % (str(gameid), str(gameversion)), 60*60) + if cache: + cachedata = json.loads(cache) + return cachedata + + url = 'http://api.steampowered.com/ISteamApps/UpToDateCheck/v1?appId={0}&version={1}'.format(gameid, gameversion) + try: + response = urlopen(url) + data = response.read().decode('utf-8') + jsondata = json.loads(data) + if 'response' in jsondata: + jsondata = jsondata['response'] + except HTTPError: + jsondata = None + + if jsondata: + if CACHE: + cache = Caching.writeCache('serverupdate', '%s-%s' % (str(gameid), str(gameversion)), json.dumps(jsondata)) + return jsondata + return None + def getMultipleUserOwnedGames(self, steamids): executor = ThreadPoolExecutor(max_workers=10) futures = dict() |