Browse Source

Moved sleep call and increased its length.

master
James Hofstra 2 months ago
parent
commit
310af42f48
1 changed files with 14 additions and 3 deletions
  1. +14
    -3
      steam_stat_utils.py

+ 14
- 3
steam_stat_utils.py View File

@@ -204,7 +204,6 @@ def get_global_stats_history(appid, names, startdate, enddate):
method = 'GetGlobalStatsForGame'
version = 1
global_stats = {}
time.sleep(1)
# Build parameters
count = len(names)
@@ -214,13 +213,17 @@ def get_global_stats_history(appid, names, startdate, enddate):
try:
resp = webapi_get(interface, method, version, params)
except urllib.error.HTTPError:
pass
except urllib.error.HTTPError as e:
print('Fetch failed for names ' + names)
print(e)
else:
resp = json.loads(resp.decode('utf-8')).get('response', {})
if resp.get('result', 0) == 1:
for stat_name, stat_data in resp['globalstats'].items():
global_stats[stat_name] = stat_data.get('history')
else:
print('Fetch failed for names ' + names)
print(resp)
return global_stats

@@ -304,6 +307,7 @@ def main_history():
for i in range(0, len(l), n):
yield l[i:i+n]
for partial_names in divide_names(global_stat_names, 4):
time.sleep(3)
global_stats = get_global_stats_history(sys.argv[2], partial_names, sys.argv[3], sys.argv[4])
global_stat_hist.update(global_stats)
# Organized in CSV file for easier spreadsheet import
@@ -312,4 +316,11 @@ def main_history():
print('No input specified.')

if __name__ == '__main__':
# Dump player stats and global stat totals. Current usage:
# steam_stat_utils.py path/to/steam appid userid
# where userid is the signed-in user's SteamID.
main()
# Fetch global stat history. Current usage:
# steam_stat_utils.py path/to/steam appid startdate enddate
# where startdate and enddate are integer timestamps.
#main_history()

Loading…
Cancel
Save