@@ -480,22 +480,75 @@ class MapInfo(Resource):
480480 #: Name of the Map
481481 map_name = str ()
482482
483+ #: Language
484+ language = str ()
485+
483486 #: Hash of referenced s2mh file
484487 s2mh_hash = str ()
485488
486489 #: URL of referenced s2mh file
487490 s2mh_url = str ()
488491
489492 def __init__ (self , info_file , filename = None , ** options ):
490- super (MapInfo , self ).__init__ (info_file , filename ,** options )
493+ super (MapInfo , self ).__init__ (info_file , filename , ** options )
491494 self .data = utils .ReplayBuffer (info_file ).read_data_struct ()
492495 self .map_name = self .data [0 ][7 ]
493496 self .language = self .data [0 ][13 ]
494- self .s2mh_hash = '' .join ([hex (ord (x ))[2 :] for x in self .data [0 ][1 ][8 :]])
495- self .s2mh_url = MapHeader .url_template .format (self .data [0 ][1 ][6 :8 ], self .s2mh_hash )
497+ parsed_hash = utils .parse_hash (self .data [0 ][1 ])
498+ self .s2mh_hash = parsed_hash ['hash' ]
499+ self .s2mh_url = MapHeader .url_template .format (parsed_hash ['server' ], self .s2mh_hash )
500+
501+ def __str__ (self ):
502+ return self .map_name
496503
497504class MapHeader (Resource ):
505+ base_url_template = 'http://{0}.depot.battle.net:1119/{1}.{2}'
498506 url_template = 'http://{0}.depot.battle.net:1119/{1}.s2mh'
507+ image_url_template = 'http://{0}.depot.battle.net:1119/{1}.s2mv'
508+
509+ #: The name of the map
510+ name = str ()
511+
512+ #: Hash of map file
513+ map_hash = str ()
514+
515+ #: Link to the map file
516+ map_url = str ()
517+
518+ #: Hash of the map image
519+ image_hash = str ()
520+
521+ #: Link to the image of the map (.s2mv)
522+ image_url = str ()
523+
524+ #: Localization dictionary, {language, url}
525+ localization_urls = dict ()
526+
527+ #: Blizzard map
528+ blizzard = False
529+
499530 def __init__ (self , header_file , filename = None , ** options ):
500- super (MapHeader , self ).__init__ (header_file , filename ,** options )
531+ super (MapHeader , self ).__init__ (header_file , filename , ** options )
501532 self .data = utils .ReplayBuffer (header_file ).read_data_struct ()
533+
534+ # Name
535+ self .name = self .data [0 ][1 ]
536+
537+ # Blizzard
538+ self .blizzard = (self .data [0 ][11 ] == 'BLIZ' )
539+
540+ # Parse image hash
541+ parsed_hash = utils .parse_hash (self .data [0 ][1 ])
542+ self .image_hash = parsed_hash ['hash' ]
543+ self .image_url = self .image_url_template .format (parsed_hash ['server' ], parsed_hash ['hash' ])
544+
545+ # Parse map hash
546+ parsed_hash = utils .parse_hash (self .data [0 ][2 ])
547+ self .map_hash = parsed_hash ['hash' ]
548+ self .map_url = self .base_url_template .format (parsed_hash ['server' ], parsed_hash ['hash' ], parsed_hash ['type' ])
549+
550+ # Parse localization hashes
551+ l18n_struct = self .data [0 ][4 ][8 ]
552+ for l in l18n_struct :
553+ parsed_hash = utils .parse_hash (l [1 ][0 ])
554+ self .localization_urls [l [0 ]] = self .base_url_template .format (parsed_hash ['server' ], parsed_hash ['hash' ], parsed_hash ['type' ])
0 commit comments