diff --git a/sc2reader/resources.py b/sc2reader/resources.py index ad80695e..50c54f9f 100644 --- a/sc2reader/resources.py +++ b/sc2reader/resources.py @@ -914,7 +914,7 @@ def __getstate__(self): class Map(Resource): - url_template = "http://{0}.depot.battle.net:1119/{1}.s2ma" + url_template = "https://{}-s2-depot.classic.blizzard.com/{}.s2ma" def __init__(self, map_file, filename=None, region=None, map_hash=None, **options): super(Map, self).__init__(map_file, filename, **options) @@ -1021,7 +1021,7 @@ class GameSummary(Resource): that the data is not necessarily in the places we expect. """ - url_template = "http://{0}.depot.battle.net:1119/{1}.s2gs" + url_template = "https://{}-s2-depot.classic.blizzard.com/{}.s2gs" #: Game speed game_speed = str() @@ -1450,9 +1450,9 @@ def __str__(self): class MapHeader(Resource): """**Experimental**""" - base_url_template = "http://{0}.depot.battle.net:1119/{1}.{2}" - url_template = "http://{0}.depot.battle.net:1119/{1}.s2mh" - image_url_template = "http://{0}.depot.battle.net:1119/{1}.s2mv" + base_url_template = "https://{}-s2-depot.classic.blizzard.com/{}.{}" + url_template = "https://{}-s2-depot.classic.blizzard.com/{}.s2mh" + image_url_template = "https://{}-s2-depot.classic.blizzard.com/{}.s2mv" #: The name of the map name = str() diff --git a/sc2reader/utils.py b/sc2reader/utils.py index c35f91f3..c4bbcd77 100644 --- a/sc2reader/utils.py +++ b/sc2reader/utils.py @@ -20,15 +20,21 @@ class DepotFile(object): """ #: The url template for all DepotFiles - url_template = "https://{0}-s2-depot.classic.blizzard.com/{1}.{2}" + url_template = "https://{}-s2-depot.classic.blizzard.com{}/{}.{}" def __init__(self, bytes): #: The server the file is hosted on self.server = bytes[4:8].decode("utf-8").strip("\x00 ") + # Used to make it possible to load maps from CN. + # This isn't needed for any other region and so is blank by default. + self.url_suffix = "" + # There is no SEA depot, use US instead if self.server == "SEA": self.server = "US" + elif self.server == "CN": + self.url_suffix = ".cn" #: The unique content based hash of the file self.hash = binascii.b2a_hex(bytes[8:]).decode("utf8") @@ -39,7 +45,9 @@ def __init__(self, bytes): @property def url(self): """Returns url of the depot file.""" - return self.url_template.format(self.server, self.hash, self.type) + return self.url_template.format( + self.server, self.url_suffix, self.hash, self.type + ) def __hash__(self): return hash(self.url)