Skip to content

Commit 22ac113

Browse files
committed
GameSummary, parse map images and localization files
1 parent 82714f8 commit 22ac113

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

sc2reader/resources.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ def read_game_strings(self):
399399

400400

401401
class GameSummary(Resource):
402+
base_url_template = 'http://{0}.depot.battle.net:1119/{1}.{2}'
402403
url_template = 'http://{0}.depot.battle.net:1119/{1}.s2gs'
403404

404405
stats_keys = [
@@ -421,6 +422,12 @@ class GameSummary(Resource):
421422
#: Players, a list of :class`PlayerSummary` from the game
422423
players = list()
423424

425+
#: Map image urls
426+
image_urls = list()
427+
428+
#: Map localization urls
429+
localization_urls = dict()
430+
424431
def __init__(self, summary_file, filename=None, **options):
425432
super(GameSummary, self).__init__(summary_file, filename,**options)
426433
self.data = zlib.decompress(summary_file.read()[16:])
@@ -472,8 +479,24 @@ def __init__(self, summary_file, filename=None, **options):
472479
p.stats[self.stats_keys[i]] = stats_struct[i][1][p.pid][0][0]
473480
# The last piece of stats is in parts[4][0][0][1]
474481
p.stats[self.stats_keys[len(stats_struct)]] = self.parts[4][0][0][1][p.pid][0][0]
475-
482+
483+
# Parse map localization data
484+
for l in self.parts[0][6][8]:
485+
lang = l[0]
486+
urls = list()
487+
for hash in l[1]:
488+
parsed_hash = utils.parse_hash(hash)
489+
if parsed_hash['server'] == '\x00\x00':
490+
continue
491+
urls.append(self.base_url_template.format(parsed_hash['server'], parsed_hash['hash'], parsed_hash['type']))
476492

493+
self.localization_urls[lang] = urls
494+
495+
# Parse map images
496+
for hash in self.parts[0][6][7]:
497+
parsed_hash = utils.parse_hash(hash)
498+
self.image_urls.append(self.base_url_template.format(parsed_hash['server'], parsed_hash['hash'], parsed_hash['type']))
499+
477500
class MapInfo(Resource):
478501
url_template = 'http://{0}.depot.battle.net:1119/{1}.s2mi'
479502

0 commit comments

Comments
 (0)