-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathWallpaperDownloader_zh.py
125 lines (106 loc) · 4.61 KB
/
WallpaperDownloader_zh.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import tkinter as tk
from tkinter import scrolledtext, filedialog
import subprocess
import threading
import base64
import re
import os
def run_command(pubfileid):
printlog(f"----------正在下载 {pubfileid}--------\n")
if 'save_location' not in globals():
printlog("错误:保存位置未正确设置。\n")
return
if not os.path.isdir(save_location):
printlog("错误:保存位置不存在。\n")
return
target_directory = os.path.join(save_location, "projects", "myprojects")
if not os.path.isdir(target_directory):
printlog("无效的保存位置:选定目录不包含 \projects\myprojects\n")
return
dir_option = f"-dir \"{save_location}\\projects\\myprojects\\{pubfileid}\""
command = f"DepotdownloaderMod\\DepotDownloadermod.exe -app 431960 -pubfile {pubfileid} -verify-all -username {username.get()} -password {passwords[username.get()]} {dir_option}"
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True,creationflags=subprocess.CREATE_NO_WINDOW)
for line in process.stdout:
printlog(line)
process.stdout.close()
process.wait()
printlog(f"-------------下载完成-----------\n")
def printlog(log):
console.config(state=tk.NORMAL)
console.insert(tk.END, log)
console.yview(tk.END)
console.config(state=tk.DISABLED)
def run_commands():
run_button.config(state=tk.DISABLED)
links = link_text.get("1.0", tk.END).splitlines()
for link in links:
if link:
match = re.search(r'\b\d{8,10}\b', link.strip())
if match:
run_command(match.group(0))
else:
printlog(f"无效链接:{link}\n")
run_button.config(state=tk.NORMAL)
def start_thread():
threading.Thread(target=run_commands).start()
def on_closing():
subprocess.Popen("taskkill /f /im DepotDownloadermod.exe", creationflags=subprocess.CREATE_NO_WINDOW)
os._exit(0)
def select_save_location():
selected_directory = filedialog.askdirectory()
target_directory = os.path.join(selected_directory, "projects", "myprojects")
if not os.path.isdir(target_directory):
printlog("无效的保存位置:选定目录不包含 \projects\myprojects\n")
else:
printlog(f"路径已设置为 {selected_directory}\n")
global save_location
save_location = selected_directory
save_location_label.config(text=f"保存位置:{selected_directory}")
with open('lastsavelocation.cfg', 'w') as file:
file.write(selected_directory)
def load_save_location():
try:
with open('lastsavelocation.cfg', 'r') as file:
target_directory = file.read().strip()
if os.path.isdir(target_directory):
global save_location
save_location = target_directory
else:
save_location = "未设置"
except FileNotFoundError:
save_location = "未设置"
accounts = {'ruiiixx': 'UzY3R0JUQjgzRDNZ',
'premexilmenledgconis': 'M3BYYkhaSmxEYg==',
'vAbuDy': 'Qm9vbHE4dmlw',
'adgjl1182': 'UUVUVU85OTk5OQ==',
'gobjj16182': 'enVvYmlhbzgyMjI=',
'787109690': 'SHVjVXhZTVFpZzE1'
}
passwords = {account: base64.b64decode(accounts[account]).decode('utf-8') for account in accounts}
load_save_location()
root = tk.Tk()
root.title("Wallpaper Engine 创意工坊下载器")
title_label = tk.Label(root, text="Wallpaper Engine 创意工坊下载器", font=("Arial", 21))
title_label.grid(row=0, column=0)
username_label = tk.Label(root, text="选择账户:")
username_label.grid(row=1, column=0, sticky='w', padx=(130, 0))
username = tk.StringVar(root)
username.set(list(accounts.keys())[0])
username_menu = tk.OptionMenu(root, username, *accounts.keys())
username_menu.grid(row=1, column=0)
save_location_button = tk.Button(root, text="选择壁纸引擎路径", command=select_save_location)
save_location_button.grid(row=2, column=0)
save_location_label = tk.Label(root, text=f"壁纸引擎路径:{save_location}")
save_location_label.grid(row=3, column=0)
link_label = tk.Label(root, text="输入创意工坊项目(每行一个,支持链接和文件ID):")
link_text = scrolledtext.ScrolledText(root, height=10)
link_label.grid(row=4, column=0)
link_text.grid(row=5, column=0)
console_label = tk.Label(root, text="控制台输出:")
console = scrolledtext.ScrolledText(root, height=10)
console_label.grid(row=6, column=0)
console.grid(row=7, column=0)
run_button = tk.Button(root, text="下载", command=start_thread)
run_button.grid(row=8, column=0)
root.protocol("WM_DELETE_WINDOW", on_closing)
root.mainloop()