13
13
from alive_progress import alive_bar
14
14
import datetime
15
15
import sys
16
+ import re
16
17
17
18
# Defined Variables
18
19
global cfg
19
20
cfg = configparser .RawConfigParser ()
20
- version = "v1.3 "
21
+ version = "1.2 "
21
22
threads = 1
22
23
get_date = datetime .datetime .now ()
23
24
month = get_date .month
24
25
25
- client_id = '945401698401284116' # Put your Client ID here, this is a fake ID
26
- RPC = Presence (client_id ) # Initialize the Presence class
27
- RPC .connect () # Start the handshake loop
26
+ # Connect to Discord RPC
27
+ client_id = '945401698401284116'
28
+ RPC = Presence (client_id )
29
+ RPC .connect ()
28
30
29
31
# Check if folder exists else create it
30
32
if os .path .exists ('temp' ):
38
40
if not os .path .exists ('configs' ):
39
41
os .makedirs ('configs' )
40
42
43
+ # Checking for updates on startup
44
+ def update_checker ():
45
+ os .system ('cls' )
46
+ header = "User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36"
47
+ git_up = "https://api.github.com/repos/Official-Husko/Husko-s-SteamWorkshop-Downloader/releases/latest"
48
+ latest = requests .get (git_up ,headers = {"User-Agent" :header }).text
49
+ git_data = json .loads (latest )
50
+ cv = str (git_data .get ('tag_name' ))
51
+ u_info = str (git_data .get ('body' ))
52
+ dir_url = str (git_data ['assets' ][0 ]['browser_download_url' ])
53
+ updt_name = str (git_data .get ('name' ))
54
+ updt_rel = str (git_data .get ('published_at' ))
55
+ if float (version ) < float (cv ):
56
+ RPC .update (state = "Updating Downloader to " + cv ,buttons = [{"label" : "GitHub" , "url" : "https://github.com/Official-Husko/Husko-s-SteamWorkshop-Downloader" },],small_text = "Updating" ,small_image = "update" ,large_image = "bridge" )
57
+ print (colored ("A new Update is available!" , "green" ))
58
+ print ("" )
59
+ print ("Name: " + colored (updt_name , "green" ))
60
+ print ("Version: " + colored (cv , "green" ))
61
+ print ("Released: " + colored (updt_rel .strip ("tz" ), "green" ))
62
+ print ("" )
63
+ print ("" )
64
+ print ("==================<[ " + colored ("What's New " , "green" ) + "]>==================" )
65
+ print (u_info )
66
+ print ("" )
67
+ sleep (3 )
68
+ print ("Download Update? (Y/n)" )
69
+ fetch_u = input (">> " )
70
+ if fetch_u == "y" or fetch_u == "Y" :
71
+ if not os .path .exists ('update' ):
72
+ os .makedirs ('update' )
73
+ fetch = requests .get (dir_url ,headers = {"User-Agent" :header },stream = True )
74
+ file_path = os .path .join ("update/" ,"Huskos SteamWorkshop Downloader.exe" )
75
+ file = open (file_path , 'wb' )
76
+ with alive_bar (int (int (fetch .headers .get ('content-length' )) / 1024 + 1 ), title = "Downloading Update" ) as bar :
77
+ for chunk in fetch .iter_content (chunk_size = 1024 ):
78
+ if chunk :
79
+ file .write (chunk )
80
+ file .flush ()
81
+ bar ()
82
+ file .close ()
83
+ print ("" )
84
+ print ("The Update has been downloaded into the downloads folder in your directory. Once you are ready you can close the bot and replace the old exe with the new one. This will not delete any of the configs!" )
85
+ sleep (5 )
86
+ sys .exit (0 )
87
+ else :
88
+ print ("Proceeding to Downloader" )
89
+ sleep (3 )
90
+ proxy_scraper (cfg )
91
+
41
92
# Set CMD Title
42
- ctypes .windll .kernel32 .SetConsoleTitleW ("Husko's Steam Workshop Downloader | " + version )
93
+ ctypes .windll .kernel32 .SetConsoleTitleW ("Husko's Steam Workshop Downloader | v " + version )
43
94
44
95
def game_selection (cfg ):
45
- RPC .update (state = "Selecting a Game" ,buttons = [{"label" : "GitHub" , "url" : "https://github.com/Official-Husko" },],small_text = "Game Selection" ,small_image = "selection" ,large_image = "bridge" )
96
+ RPC .update (state = "Selecting a Game" ,buttons = [{"label" : "GitHub" , "url" : "https://github.com/Official-Husko/Husko-s-SteamWorkshop-Downloader " },],small_text = "Game Selection" ,small_image = "selection" ,large_image = "bridge" )
46
97
os .system ('cls' )
47
98
print (colored ("======================================================================================================================" , "red" ))
48
99
print (colored ("| |" , "red" ))
@@ -96,17 +147,17 @@ def config(cfg):
96
147
print ("Proxies Loaded: " + colored (str (len (proxy_list )), "green" ))
97
148
print ("" )
98
149
print ("Please Enter the Workshop Link" )
99
- RPC .update (state = "Looking for a mod to Download" ,buttons = [{"label" : "GitHub" , "url" : "https://github.com/Official-Husko" },],small_text = game_names .get (game ),small_image = config_names .get (game ),large_image = "bridge" )
150
+ RPC .update (state = "Looking for a mod to Download" ,buttons = [{"label" : "GitHub" , "url" : "https://github.com/Official-Husko/Husko-s-SteamWorkshop-Downloader " },],small_text = game_names .get (game ),small_image = config_names .get (game ),large_image = "bridge" )
100
151
config2 (cfg )
101
152
102
153
103
154
def config2 (cfg ):
104
- RPC .update (state = "Looking for a mod to Download" ,buttons = [{"label" : "GitHub" , "url" : "https://github.com/Official-Husko" },],small_text = game_names .get (game ),small_image = config_names .get (game ),large_image = "bridge" )
155
+ RPC .update (state = "Looking for a mod to Download" ,buttons = [{"label" : "GitHub" , "url" : "https://github.com/Official-Husko/Husko-s-SteamWorkshop-Downloader " },],small_text = game_names .get (game ),small_image = config_names .get (game ),large_image = "bridge" )
105
156
global id
106
157
global xid
107
158
xid = input (colored (">> " , ))
108
- xxid = xid . strip ( "https://steamcommunity.com/sharedfiles/filedetails/?id=" )
109
- id = xxid .strip ("&searchtext =" )
159
+ xxid = re . match ( r"(.*\d+)" , xid ). group ( )
160
+ id = xxid .strip ("https://steamcommunity.com/sharedfiles/filedetails/?id =" )
110
161
if id .isnumeric () == False :
111
162
print (colored ("Something Went Wrong! Either wrong workshop URL or another error." , "red" ))
112
163
sleep (5 )
@@ -128,18 +179,22 @@ def downloader(cfg):
128
179
page = requests .post (url ,headers = {"User-Agent" :header },proxies = proxyy ,timeout = timeout ,data = mod_id ).text
129
180
else :
130
181
page = requests .post (url ,headers = {"User-Agent" :header },timeout = timeout ,data = mod_id ).text
182
+ if page == "[]" :
183
+ print (colored ("Mod Not Found. If this seems to be a mistake please open an issue report." , "red" ))
184
+ sleep (3 )
185
+ config2 (cfg )
131
186
data = json .loads (page )
132
187
for i in data :
133
188
pubid = str (i .get ('publishedfileid' ))
134
189
safe_name = str (i .get ('title_disk_safe' ))
135
190
name = str (i .get ('title' ))
136
191
app_id = str (i .get ('creator_appid' ))
137
192
if int (app_id ) != int (game ):
138
- print ("You Tried to download a mod for a different game then you selected!" )
193
+ print (colored ( "You Tried to download a mod for a different game then you selected!" , "red" ) )
139
194
sleep (3 )
140
195
game_selection (cfg )
141
196
print ("Downloading: " + colored (name , "green" ))
142
- RPC .update (details = "Downloading " + name ,buttons = [{"label" : "GitHub" , "url" : "https://github.com/Official-Husko" },{"label" : "Mod Page" , "url" : "" + xid + "" }],small_text = "Stormworks: Build and Rescue" ,small_image = "stormworks" ,large_image = "bridge" )
197
+ RPC .update (details = "Downloading " + name ,buttons = [{"label" : "GitHub" , "url" : "https://github.com/Official-Husko/Husko-s-SteamWorkshop-Downloader " },{"label" : "Mod Page" , "url" : "" + xid + "" }],small_text = "Stormworks: Build and Rescue" ,small_image = "stormworks" ,large_image = "bridge" )
143
198
url2 = "https://" + bd + ".steamworkshopdownloader.io/prod/api/download/request"
144
199
req_data = '{"publishedFileId":' + pubid + ',"collectionId":null,"hidden":false,"downloadFormat":"raw","autodownload":false}'
145
200
if proxies == "yes" :
@@ -182,10 +237,7 @@ def downloader(cfg):
182
237
r = requests .get (url4 ,headers = {"User-Agent" :header },timeout = timeout ,stream = True )
183
238
file_path = os .path .join ("temp/" , safe_name + ".zip" )
184
239
file = open (file_path , 'wb' )
185
- style = "smooth"
186
- if month == 10 :
187
- style = "halloween"
188
- with alive_bar (int (int (r .headers .get ('content-length' )) / 1024 + 1 ),bar = style ) as bar :
240
+ with alive_bar (int (int (r .headers .get ('content-length' )) / 1024 + 1 )) as bar :
189
241
for chunk in r .iter_content (chunk_size = 1024 ):
190
242
if chunk :
191
243
file .write (chunk )
@@ -365,7 +417,7 @@ def proxy_scraper(cfg):
365
417
game_selection (cfg )
366
418
367
419
if __name__ == '__main__' :
368
- proxy_scraper ( cfg )
420
+ update_checker ( )
369
421
370
422
# Credits
371
423
#
0 commit comments