Add version to download folder
This commit is contained in:
parent
29e3a425a3
commit
c533330f1a
1
.gitignore
vendored
1
.gitignore
vendored
@ -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
|
||||
|
@ -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])
|
||||
|
Loading…
Reference in New Issue
Block a user