Skip to content

Commit 0795bfa

Browse files
committed
url_template updates
load_map=True should now work on CN and NA out of the box. Updated the other url_templates to use the new blizzard CDN, although I neglected to include CN in them as adding it would be a bit more effort/it seems those were rarely used anyway since no one complained they were broken.
1 parent af3628e commit 0795bfa

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

sc2reader/resources.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ def __getstate__(self):
914914

915915

916916
class Map(Resource):
917-
url_template = "http://{0}.depot.battle.net:1119/{1}.s2ma"
917+
url_template = "https://{0}-s2-depot.classic.blizzard.com/{1}.s2ma"
918918

919919
def __init__(self, map_file, filename=None, region=None, map_hash=None, **options):
920920
super(Map, self).__init__(map_file, filename, **options)
@@ -1021,7 +1021,7 @@ class GameSummary(Resource):
10211021
that the data is not necessarily in the places we expect.
10221022
"""
10231023

1024-
url_template = "http://{0}.depot.battle.net:1119/{1}.s2gs"
1024+
url_template = "https://{0}-s2-depot.classic.blizzard.com/{1}.s2gs"
10251025

10261026
#: Game speed
10271027
game_speed = str()
@@ -1450,9 +1450,9 @@ def __str__(self):
14501450
class MapHeader(Resource):
14511451
"""**Experimental**"""
14521452

1453-
base_url_template = "http://{0}.depot.battle.net:1119/{1}.{2}"
1454-
url_template = "http://{0}.depot.battle.net:1119/{1}.s2mh"
1455-
image_url_template = "http://{0}.depot.battle.net:1119/{1}.s2mv"
1453+
base_url_template = "https://{0}-s2-depot.classic.blizzard.com/{1}.{2}"
1454+
url_template = "https://{0}-s2-depot.classic.blizzard.com/{1}.s2mh"
1455+
image_url_template = "https://{0}-s2-depot.classic.blizzard.com/{1}.s2mv"
14561456

14571457
#: The name of the map
14581458
name = str()

sc2reader/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ class DepotFile(object):
2020
"""
2121

2222
#: The url template for all DepotFiles
23-
url_template = "https://{0}-s2-depot.classic.blizzard.com/{1}.{2}"
23+
url_template = "https://{0}-s2-depot.classic.blizzard.com{1}/{2}.{3}"
2424

2525
def __init__(self, bytes):
2626
#: The server the file is hosted on
2727
self.server = bytes[4:8].decode("utf-8").strip("\x00 ")
28-
28+
#: Used to make it possible to load maps from CN. This isn't needed for any other region and so is blank by default.
29+
self.urlEnd = ""
2930
# There is no SEA depot, use US instead
3031
if self.server == "SEA":
3132
self.server = "US"
33+
elif self.server == "CN":
34+
self.urlEnd = ".cn"
3235

3336
#: The unique content based hash of the file
3437
self.hash = binascii.b2a_hex(bytes[8:]).decode("utf8")
@@ -39,7 +42,7 @@ def __init__(self, bytes):
3942
@property
4043
def url(self):
4144
"""Returns url of the depot file."""
42-
return self.url_template.format(self.server, self.hash, self.type)
45+
return self.url_template.format(self.server, self.urlEnd, self.hash, self.type)
4346

4447
def __hash__(self):
4548
return hash(self.url)

0 commit comments

Comments
 (0)