|
17 | 17 | INCLUDE_SNAPSHOT = False |
18 | 18 |
|
19 | 19 |
|
| 20 | +def get_http(url: str) -> str: |
| 21 | + """Strip https from the url.""" |
| 22 | + if url.startswith("https://"): |
| 23 | + return "http" + url[5:] |
| 24 | + return url |
| 25 | + |
| 26 | + |
20 | 27 | def get_launcher_manifest() -> dict: |
21 | 28 | global launcher_manifest |
22 | 29 | if launcher_manifest is None: |
23 | 30 | log.info("Downloading java launcher manifest file.") |
24 | 31 | with urlopen( |
25 | | - "https://launchermeta.mojang.com/mc/game/version_manifest.json", timeout=20 |
| 32 | + get_http("https://launchermeta.mojang.com/mc/game/version_manifest.json"), |
| 33 | + timeout=20, |
26 | 34 | ) as manifest: |
27 | 35 | launcher_manifest = json.load(manifest) |
28 | 36 | log.info("Finished downloading java launcher manifest file.") |
@@ -56,13 +64,13 @@ def get_latest_iter() -> Generator[float, None, JavaResourcePack]: |
56 | 64 | new_version = get_launcher_manifest()["latest"]["snapshot"] |
57 | 65 | else: |
58 | 66 | new_version = get_launcher_manifest()["latest"]["release"] |
59 | | - except Exception as e: |
| 67 | + except Exception: |
60 | 68 | if os.path.isdir(vanilla_rp_path): |
61 | 69 | log.error( |
62 | 70 | "Could not download the launcher manifest. The resource pack seems to be present so using that." |
63 | 71 | ) |
64 | 72 | else: |
65 | | - raise e |
| 73 | + raise |
66 | 74 | else: |
67 | 75 | has_new_pack = False |
68 | 76 | if os.path.isfile(os.path.join(vanilla_rp_path, "version")): |
@@ -166,11 +174,11 @@ def download_resources_iter( |
166 | 174 | raise Exception(f"Could not find Java resource pack for version {version}.") |
167 | 175 |
|
168 | 176 | try: |
169 | | - with urlopen(version_url, timeout=20) as vm: |
| 177 | + with urlopen(get_http(version_url), timeout=20) as vm: |
170 | 178 | version_manifest = json.load(vm) |
171 | 179 | version_client_url = version_manifest["downloads"]["client"]["url"] |
172 | 180 |
|
173 | | - downloader = download_with_retry(version_client_url) |
| 181 | + downloader = download_with_retry(get_http(version_client_url)) |
174 | 182 | try: |
175 | 183 | while True: |
176 | 184 | yield next(downloader) / 2 |
@@ -203,10 +211,10 @@ def download_resources_iter( |
203 | 211 | if "pack.png" in client.namelist(): |
204 | 212 | client.extract("pack.png", path) |
205 | 213 |
|
206 | | - except Exception as e: |
| 214 | + except Exception: |
207 | 215 | log.error( |
208 | 216 | f"Failed to download and extract the Java resource pack for version {version}.", |
209 | 217 | exc_info=True, |
210 | 218 | ) |
211 | | - raise e |
| 219 | + raise |
212 | 220 | log.info(f"Finished downloading Java resource pack for version {version}") |
0 commit comments