Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
Andrene committed Aug 16, 2021
commit 0795bfae9c3ef50a452d7af60387c08b2b17b19d
10 changes: 5 additions & 5 deletions sc2reader/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ def __getstate__(self):


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

def __init__(self, map_file, filename=None, region=None, map_hash=None, **options):
super(Map, self).__init__(map_file, filename, **options)
Expand Down Expand Up @@ -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://{0}-s2-depot.classic.blizzard.com/{1}.s2gs"

#: Game speed
game_speed = str()
Expand Down Expand Up @@ -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://{0}-s2-depot.classic.blizzard.com/{1}.{2}"
url_template = "https://{0}-s2-depot.classic.blizzard.com/{1}.s2mh"
image_url_template = "https://{0}-s2-depot.classic.blizzard.com/{1}.s2mv"

#: The name of the map
name = str()
Expand Down
9 changes: 6 additions & 3 deletions sc2reader/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ class DepotFile(object):
"""

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

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.urlEnd = ""
# There is no SEA depot, use US instead
if self.server == "SEA":
self.server = "US"
elif self.server == "CN":
self.urlEnd = ".cn"

#: The unique content based hash of the file
self.hash = binascii.b2a_hex(bytes[8:]).decode("utf8")
Expand All @@ -39,7 +42,7 @@ 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.urlEnd, self.hash, self.type)

def __hash__(self):
return hash(self.url)
Expand Down