Skip to content

Commit 25858de

Browse files
committed
Found two timestamps in the .s2gs files, added to GameSummary
1 parent 22ac113 commit 25858de

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

sc2reader/resources.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pprint
55
import hashlib
66
from datetime import datetime
7+
import time
78
from StringIO import StringIO
89
from collections import defaultdict
910

@@ -419,6 +420,12 @@ class GameSummary(Resource):
419420
#: Game speed
420421
game_speed = str()
421422

423+
#: ? time, unknown what this represents, but it's close to game completion time
424+
#: unix
425+
time1 = int()
426+
#: time2 seems to be more accurate than time1
427+
time2 = int()
428+
422429
#: Players, a list of :class`PlayerSummary` from the game
423430
players = list()
424431

@@ -440,6 +447,15 @@ def __init__(self, summary_file, filename=None, **options):
440447
# Parse basic info
441448
self.game_speed = GAME_SPEED_CODES[''.join(reversed(self.parts[0][0][1]))]
442449

450+
# time struct looks like this:
451+
# { 0: 11987, 1: 283385849, 2: 1334719793L}
452+
# 0, 1 might be an adjustment of some sort
453+
self.time1 = self.parts[0][2][2]
454+
455+
# this one is alone
456+
# but there is an int above it @ parts[0][7]
457+
self.time2 = self.parts[0][8]
458+
443459
# Parse player structs, 16 is the maximum amount of players
444460
for i in range(16):
445461
player = None
@@ -497,6 +513,10 @@ def __init__(self, summary_file, filename=None, **options):
497513
parsed_hash = utils.parse_hash(hash)
498514
self.image_urls.append(self.base_url_template.format(parsed_hash['server'], parsed_hash['hash'], parsed_hash['type']))
499515

516+
def __str__(self):
517+
return "{} - {}".format(time.ctime(self.time2),
518+
''.join(p.race[0] for p in self.players))
519+
500520
class MapInfo(Resource):
501521
url_template = 'http://{0}.depot.battle.net:1119/{1}.s2mi'
502522

0 commit comments

Comments
 (0)