diff --git a/.gitignore b/.gitignore index d2193dd..ac6e704 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ downloads/ # Fallback in case files are not in the downloads folder *.7z +VERSION # Ignore the build folder __pycache__/ # Ignore environment files diff --git a/download.py b/download.py index 6de00c7..1ea7dc1 100644 --- a/download.py +++ b/download.py @@ -86,10 +86,16 @@ def download_file(edit): opener = build_opener() print("Download link: ", download_link) opener.addheaders = [("apikey", API_KEY), ("User-Agent", "Mozilla/5.0")] + + # Create directories if they don't exist filename = f"{edit['name']} {edit['version']}.7z" path = f"./downloads/{edit['name']}/{filename}" if not os.path.exists(os.path.dirname(path)): os.makedirs(os.path.dirname(path)) + + # Write VERSION file + with open(f"./downloads/{edit['name']}/VERSION", "w") as version_file: + version_file.write(edit["version"]) # If file already exists, skip download if os.path.exists(path): print(f"File {filename} already exists, skipping download...") @@ -98,6 +104,7 @@ def download_file(edit): with open(path, "wb") as file: file.write(response.read()) + for edit in xEdits: print(f"Downloading {edit}...") download_file(xEdits[edit])