Skip to content
Merged
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
fix for CN
  • Loading branch information
HADB committed Sep 7, 2021
commit 7bc551e40671e27e7d0ead58b9dc5ae1577d3186
10 changes: 6 additions & 4 deletions sc2reader/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,23 @@ class DepotFile(object):
"""

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

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 = ""
self.scheme = "https"
self.domain = "classic.blizzard.com"

# There is no SEA depot, use US instead
if self.server == "SEA":
self.server = "US"
elif self.server == "CN":
self.url_suffix = ".cn"
self.scheme = "http"
self.domain = "battlenet.com.cn"

#: The unique content based hash of the file
self.hash = binascii.b2a_hex(bytes[8:]).decode("utf8")
Expand All @@ -46,7 +48,7 @@ def __init__(self, bytes):
def url(self):
"""Returns url of the depot file."""
return self.url_template.format(
self.server, self.url_suffix, self.hash, self.type
self.scheme, self.server, self.domain, self.hash, self.type
)

def __hash__(self):
Expand Down