-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathpull-assembly-patches.py
More file actions
41 lines (31 loc) · 1.15 KB
/
pull-assembly-patches.py
File metadata and controls
41 lines (31 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import shutil
import tempfile
import urllib.request
from pathlib import Path
from zipfile import ZipFile
import requests
VERSION = "0.12.2"
ASSET_NAME = "Randomizer.Patches.zip"
DESTINATION_ASSEMBLY_PATH = (
Path(__file__)
.parent.resolve()
.joinpath("src", "mars_patcher", "mf", "data", "patches", "mf_u", "asm")
)
release_url = f"https://api.github.com/repos/MetroidAdvRandomizerSystem/mars-fusion-asm/releases/tags/{VERSION}"
print(f"Fetching {release_url}")
response = requests.get(release_url).json()
for asset in response["assets"]:
if asset["name"] != ASSET_NAME:
continue
print("Correct release found, initalizing download")
with tempfile.TemporaryDirectory() as temp_ref:
temp_dir = Path(temp_ref)
temp_file = temp_dir.joinpath("cache.zip")
urllib.request.urlretrieve(asset["browser_download_url"], temp_file)
with ZipFile(temp_file, "r") as zip_ref:
zip_ref.extractall(temp_dir)
for file in list(temp_dir.joinpath("bin").iterdir()):
print(f"Moving {file.name}")
shutil.move(file, DESTINATION_ASSEMBLY_PATH.joinpath(file.name))
break
print("Done.")