-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMirrorHandler.py
More file actions
38 lines (29 loc) · 1.23 KB
/
MirrorHandler.py
File metadata and controls
38 lines (29 loc) · 1.23 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
import urllib.request, json, config
mirror = config.MIRROR_URL
def Download(url: str, path: str):
urllib.request.urlretrieve(url=url, filename=path)
def DecompilerJars(versionData: json):
Download(versionData["decompiler"]["CFR"], "./jars/CFR.jar")
Download(versionData["decompiler"]["SpecialSource"], "./jars/SpecialSource.jar")
Download(versionData["decompiler"]["client"], "./jars/client/client.jar")
Download(versionData["decompiler"]["server"], "./jars/server/server.jar")
def ParseVersion():
with urllib.request.urlopen(mirror) as url:
data = json.loads(url.read().decode())
versions = list(data["version"].keys())
if not versions:
print("No versions avalible in mirror")
exit()
for i, version in enumerate(versions, 0):
print(f"[{i}] --->>> {version}")
global select
select = None
while True:
id = int(input(f"\nSELECT (0-{len(versions)-1}): "))
if id < 0 or id > len(versions):
print("Bruh..")
pass
select = versions[id]
print(f"VERSION: {select}")
break
return data["version"][select]