Skip to content

Commit 44e0f33

Browse files
authored
Merge pull request #151 from Andrene/upstream
url_template updates
2 parents af3628e + b68cc48 commit 44e0f33

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
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://{}-s2-depot.classic.blizzard.com/{}.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://{}-s2-depot.classic.blizzard.com/{}.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://{}-s2-depot.classic.blizzard.com/{}.{}"
1454+
url_template = "https://{}-s2-depot.classic.blizzard.com/{}.s2mh"
1455+
image_url_template = "https://{}-s2-depot.classic.blizzard.com/{}.s2mv"
14561456

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

sc2reader/utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,21 @@ 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://{}-s2-depot.classic.blizzard.com{}/{}.{}"
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 ")
2828

29+
# Used to make it possible to load maps from CN.
30+
# This isn't needed for any other region and so is blank by default.
31+
self.url_suffix = ""
32+
2933
# There is no SEA depot, use US instead
3034
if self.server == "SEA":
3135
self.server = "US"
36+
elif self.server == "CN":
37+
self.url_suffix = ".cn"
3238

3339
#: The unique content based hash of the file
3440
self.hash = binascii.b2a_hex(bytes[8:]).decode("utf8")
@@ -39,7 +45,9 @@ def __init__(self, bytes):
3945
@property
4046
def url(self):
4147
"""Returns url of the depot file."""
42-
return self.url_template.format(self.server, self.hash, self.type)
48+
return self.url_template.format(
49+
self.server, self.url_suffix, self.hash, self.type
50+
)
4351

4452
def __hash__(self):
4553
return hash(self.url)

0 commit comments

Comments
 (0)