forked from fidget77/WorkshopDL
-
Notifications
You must be signed in to change notification settings - Fork 20
/
click me before first run.py
44 lines (36 loc) · 1.29 KB
/
click me before first run.py
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
42
43
44
import os
import zipfile
import requests
# List of URLs to try for downloading the file
file_urls = [
"https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip",
"http://web.archive.org/web/2/https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip", # Wayback Machine
# mirror URL
]
# Directory where you want to save the downloaded file and extract it
output_directory = "steamcmd"
# Path to the downloaded zip file
zip_file_path = os.path.join(output_directory, "steamcmd.zip")
# Create the output directory if it doesn't exist
os.makedirs(output_directory, exist_ok=True)
download_successful = False
for url in file_urls:
response = requests.get(url, allow_redirects=True)
if response.status_code == 200:
with open(zip_file_path, 'wb') as f:
f.write(response.content)
print(f"Downloaded {zip_file_path}")
download_successful = True
break
else:
print(f"Failed to download {url}")
if not download_successful:
print("All download attempts failed. Exiting.")
exit(1)
# Extract the zip file
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
zip_ref.extractall(output_directory)
print(f"Extracted contents to {output_directory}")
# Delete the zip file
os.remove(zip_file_path)
print(f"Deleted {zip_file_path}")