-
Notifications
You must be signed in to change notification settings - Fork 0
/
Download_bds.py
64 lines (55 loc) · 1.71 KB
/
Download_bds.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
##################### CONFIG #####################
ssl = True # True or False, True=https
address = "minecraft.azureedge.net"
path = "/bin-win/bedrock-server-1.18.11.01.zip"
dstFile = "./bds-temp.zip"
timeout = 10
###################### MAIN ######################
import http
import http.client
import os
import zipfile
print("Do you accept the Minecraft EULA(https://minecraft.net/terms)?")
print("您是否接受 Minecraft EULA(https://minecraft.net/terms)?")
ac = input("(y=Yes, n=No)")
if ac != "y":
exit()
conn = None
s = ""
if ssl:
conn = http.client.HTTPSConnection(address, timeout = timeout)
s = "https://"
else:
conn = http.client.HTTPConnection(address, timeout = timeout)
s = "http://"
print("Downloading BDS from", s + address + path)
print("BDS核心来自", s + address + path)
conn.request("GET", path)
res = conn.getresponse()
print("HTTP: GET Response Status:", res.status, res.reason)
print("HTTP: 获得响应", res.status, res.reason)
if res.status != 200:
print("HTTP: Error occured, exiting...")
print("HTTP:出现错误, 退出...")
exit()
data = res.read()
print("HTTP: Downloaded", len(data), "bytes")
print("HTTP: 下载", len(data), "字节")
print("Saving file...")
print("保存文件中...")
os.fdopen(os.open(dstFile, os.O_WRONLY | os.O_CREAT, 0o755), 'wb').write(data)
print("Saved")
print("保存")
zip = zipfile.ZipFile(dstFile)
print("Extracting...")
print("提取中...")
zip.extractall("./")
zip.close()
print("Extracted, deleting zip file...")
print("正在解压后删除zip文件...")
os.remove(dstFile)
print("Run LLPeEditor.exe")
print("运行LLPeEditor.exe中...")
os.system("LLPeEditor.exe")
print("Finished")
print("完成")