19
19
# Defined Variables
20
20
global cfg
21
21
cfg = configparser .RawConfigParser ()
22
- version = "1.5 "
22
+ version = "1.6 "
23
23
threads = 1
24
24
get_date = datetime .datetime .now ()
25
25
month = get_date .month
44
44
if not os .path .exists ('configs' ):
45
45
os .makedirs ('configs' )
46
46
47
+
48
+
47
49
# Checking for updates on startup
48
50
def update_checker ():
49
- os .system ('cls' )
50
- 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"
51
- git_up = "https://api.github.com/repos/Official-Husko/Husko-s-SteamWorkshop-Downloader/releases/latest"
52
- latest = requests .get (git_up ,headers = {"User-Agent" :header }).text
53
- git_data = json .loads (latest )
54
- cv = str (git_data .get ('tag_name' ))
55
- u_info = str (git_data .get ('body' ))
56
- dir_url = str (git_data ['assets' ][0 ]['browser_download_url' ])
57
- updt_name = str (git_data .get ('name' ))
58
- updt_rel = str (git_data .get ('published_at' ))
59
- if float (version ) < float (cv ):
60
- if discord_active == 1 :
61
- 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" )
62
- print (colored ("A new Update is available!" , "green" ))
63
- print ("" )
64
- print ("Name: " + colored (updt_name , "green" ))
65
- print ("Version: " + colored (cv , "green" ))
66
- print ("Released: " + colored (updt_rel .strip ("tz" ), "green" ))
67
- print ("" )
68
- print ("" )
69
- print ("==================<[ " + colored ("What's New " , "green" ) + "]>==================" )
70
- print (u_info )
71
- print ("" )
72
- sleep (3 )
73
- print ("Download Update? (Y/n)" )
74
- fetch_u = input (">> " )
75
- if fetch_u == "y" or fetch_u == "Y" :
76
- if not os .path .exists ('update' ):
77
- os .makedirs ('update' )
78
- fetch = requests .get (dir_url ,headers = {"User-Agent" :header },stream = True )
79
- file_path = os .path .join ("update/" ,"Huskos SteamWorkshop Downloader.exe" )
80
- file = open (file_path , 'wb' )
81
- with alive_bar (int (int (fetch .headers .get ('content-length' )) / 1024 + 1 ), title = "Downloading Update" ) as bar :
82
- for chunk in fetch .iter_content (chunk_size = 1024 ):
83
- if chunk :
84
- file .write (chunk )
85
- file .flush ()
86
- bar ()
87
- file .close ()
51
+ if check_for_updates == "yes" :
52
+ os .system ('cls' )
53
+ 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"
54
+ git_up = "https://api.github.com/repos/Official-Husko/Husko-s-SteamWorkshop-Downloader/releases/latest"
55
+ latest = requests .get (git_up ,headers = {"User-Agent" :header }).text
56
+ git_data = json .loads (latest )
57
+ cv = str (git_data .get ('tag_name' ))
58
+ u_info = str (git_data .get ('body' ))
59
+ dir_url = str (git_data ['assets' ][0 ]['browser_download_url' ])
60
+ updt_name = str (git_data .get ('name' ))
61
+ updt_rel = str (git_data .get ('published_at' ))
62
+ if float (version ) < float (cv ):
63
+ if discord_active == 1 :
64
+ 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" )
65
+ print (colored ("A new Update is available!" , "green" ))
66
+ print ("" )
67
+ print ("Name: " + colored (updt_name , "green" ))
68
+ print ("Version: " + colored (cv , "green" ))
69
+ print ("Released: " + colored (updt_rel .strip ("tz" ), "green" ))
70
+ print ("" )
71
+ print ("" )
72
+ print ("==================<[ " + colored ("What's New " , "green" ) + "]>==================" )
73
+ print (u_info )
88
74
print ("" )
89
- print ("The Update has been downloaded into the update folder in your directory. the bot will close so you can replace the old exe with the new one. This will not delete any of the configs!" )
90
- sleep (5 )
91
- sys .exit (0 )
92
- else :
93
- print ("Proceeding to Downloader" )
94
75
sleep (3 )
76
+ print ("Download Update? (Y/n)" )
77
+ fetch_u = input (">> " )
78
+ if fetch_u == "y" or fetch_u == "Y" :
79
+ if not os .path .exists ('update' ):
80
+ os .makedirs ('update' )
81
+ fetch = requests .get (dir_url ,headers = {"User-Agent" :header },stream = True )
82
+ file_path = os .path .join ("update/" ,"Huskos SteamWorkshop Downloader.exe" )
83
+ file = open (file_path , 'wb' )
84
+ with alive_bar (int (int (fetch .headers .get ('content-length' )) / 1024 + 1 ), title = "Downloading Update" ) as bar :
85
+ for chunk in fetch .iter_content (chunk_size = 1024 ):
86
+ if chunk :
87
+ file .write (chunk )
88
+ file .flush ()
89
+ bar ()
90
+ file .close ()
91
+ print ("" )
92
+ print ("The Update has been downloaded into the update folder in your directory. the bot will close so you can replace the old exe with the new one. This will not delete any of the configs!" )
93
+ sleep (5 )
94
+ sys .exit (0 )
95
+ else :
96
+ print ("Proceeding to Downloader" )
97
+ sleep (3 )
98
+ proxy_scraper (cfg )
99
+ else :
95
100
proxy_scraper (cfg )
96
101
else :
97
102
proxy_scraper (cfg )
@@ -177,6 +182,7 @@ def config(cfg):
177
182
178
183
179
184
def config2 (cfg ):
185
+ ctypes .windll .kernel32 .SetConsoleTitleW ("Husko's Steam Workshop Downloader | v" + version )
180
186
if discord_active == 1 :
181
187
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" )
182
188
global id
@@ -188,6 +194,7 @@ def config2(cfg):
188
194
xxid = xid .strip ("https://steamcommunity.com/sharedfiles/filedetails/?id=" )
189
195
else :
190
196
print (colored ("Something Went Wrong! Either wrong workshop URL or another error." , "red" ))
197
+ print ("" )
191
198
sleep (5 )
192
199
config2 (cfg )
193
200
id = re .match (r"(.*\d+)" , xxid ).group ()
@@ -200,8 +207,15 @@ def config2(cfg):
200
207
downloader (cfg )
201
208
202
209
def downloader (cfg ):
210
+ if create_mod_list == "yes" :
211
+ counter = 0
212
+ filename = config_names .get (game ) + "_modlist{}.txt"
213
+ while os .path .isfile (filename .format (counter )):
214
+ counter += 1
215
+ filename = filename .format (counter )
216
+ current_pos = 0
203
217
for id in collection :
204
- backend = ["node01 " ,"node02 " ,"node03 " ,"node04 " ,"node05 " ]
218
+ backend = ["node04 " ,"node05 " ,"node06 " ,"node07 " ,"node08 " ]
205
219
bd = random .choice (backend )
206
220
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"
207
221
url = "https://" + bd + ".steamworkshopdownloader.io/prod/api/details/file"
@@ -299,22 +313,27 @@ def downloader(cfg):
299
313
file .flush ()
300
314
bar ()
301
315
file .close ()
302
- zip = "temp/" + safe_name + '.zip'
303
- destination = 'temp/' + safe_name
316
+ if not_supported == True :
317
+ destination = 'manual/' + safe_name
318
+ if not os .path .exists ('manual' ):
319
+ os .makedirs ('manual' )
320
+ else :
321
+ destination = 'temp/' + safe_name
304
322
badzip = False
323
+ zip = destination + '.zip'
305
324
with zipfile .ZipFile (zip ) as zf :
306
325
try :
307
326
zf .extractall (destination )
308
327
except zipfile .BadZipFile :
309
- print (colored ("Received Corrupt Zip File. Try to download the mod again. If the issue persists try to open it manually and if it works report this issue to the mod author else the server sent a corrupt file." , "red" ))
328
+ print (colored ("Received Corrupt Zip File. Try to download the mod again. If the issue persists try to open it manually and if it works report this issue to me on github else the server sent a corrupt file." , "red" ))
310
329
badzip = True
311
330
os .remove ("temp/" + safe_name + ".zip" )
312
331
if not_supported == True :
313
- print ("You can now proceed to manually install the mod " + colored (name , "green" ) + " located in the temp folder." )
332
+ print ("You can now proceed to manually install the mod " + colored (name , "green" ) + " located in the manual folder." )
314
333
print ("" )
315
334
collection .clear ()
316
335
config2 (cfg )
317
-
336
+
318
337
# Stormworks: Build and Rescue
319
338
if int (game ) == 573090 :
320
339
@@ -351,13 +370,16 @@ def downloader(cfg):
351
370
# Project Zomboid
352
371
elif int (game ) == 108600 :
353
372
mod_path = mods + "/mods/"
354
- file_names = os .listdir (destination + '/mods' )
355
- for file_name in file_names :
356
- shutil .rmtree (mod_path + file_name , ignore_errors = True )
357
- shutil .move (os .path .join (destination + '/mods' , file_name ), mod_path )
358
-
359
- # Hunt and Snare
360
- elif int (game ) == 944330 :
373
+ try :
374
+ file_names = os .listdir (destination + '/mods' )
375
+ for file_name in file_names :
376
+ shutil .rmtree (mod_path + file_name , ignore_errors = True )
377
+ shutil .move (os .path .join (destination + '/mods' , file_name ), mod_path )
378
+ except :
379
+ yes = False
380
+
381
+ # Hunt and Snare & Call to Arms - Gates of Hell: Ostfront
382
+ elif int (game ) == 944330 or 400750 or 1118200 :
361
383
mod_path = mods + safe_name
362
384
if os .path .exists (mod_path ):
363
385
shutil .rmtree (mod_path , ignore_errors = True )
@@ -377,13 +399,14 @@ def downloader(cfg):
377
399
for file_name in file_names :
378
400
shutil .move (os .path .join ("temp/" , file_name ), mod_path )
379
401
380
- # Call to Arms - Gates of Hell: Ostfront
381
- elif int (game ) == 400750 :
382
- mod_path = mods + safe_name
383
- if os .path .exists (mod_path ):
384
- shutil . rmtree (mod_path , ignore_errors = True )
402
+ # Ravenfield
403
+ elif int (game ) == 636480 :
404
+ mod_path = mods
405
+ if not os .path .exists (mod_path ):
406
+ os . makedirs (mod_path )
385
407
source_dir = 'temp/'
386
408
file_names = os .listdir (source_dir )
409
+ shutil .rmtree (mod_path + "/" + safe_name , ignore_errors = True )
387
410
for file_name in file_names :
388
411
shutil .move (os .path .join ("temp/" , file_name ), mod_path )
389
412
@@ -393,6 +416,10 @@ def downloader(cfg):
393
416
print ("Mod " + colored (name , "red" ) + " Failed to Install!" )
394
417
else :
395
418
print ("Mod " + colored (name , "green" ) + " Successfully Installed!" )
419
+ with open (config_names .get (game ) + "_modlist.txt" , "a" ) as wmf :
420
+ wmf .write (xid + '\n ' )
421
+ current_pos += 1
422
+ ctypes .windll .kernel32 .SetConsoleTitleW ("Husko's Steam Workshop Downloader | " + str (current_pos ) + "/" + str (amount ) + " | v" + version )
396
423
print ("" )
397
424
shutil .rmtree ('temp' , ignore_errors = True )
398
425
os .makedirs ('temp' )
@@ -457,23 +484,35 @@ def downloader(cfg):
457
484
108600 ,
458
485
944330 ,
459
486
294100 ,
460
- 400750
487
+ 400750 ,
488
+ 824270 ,
489
+ 4000 ,
490
+ 1118200 ,
491
+ 636480
461
492
]
462
493
463
494
config_names = {
464
495
573090 : "stormworks" ,
465
496
108600 : "pz" ,
466
497
944330 : "hunt_snare" ,
467
498
294100 : "rimworld" ,
468
- 400750 : "cta_goh"
499
+ 400750 : "cta_goh" ,
500
+ 824270 : "kovaaks" ,
501
+ 4000 : "gmod" ,
502
+ 1118200 : "people_pg" ,
503
+ 636480 : "ravenfield"
469
504
}
470
505
471
506
game_names = {
472
507
573090 : "Stormworks: Build and Rescue" ,
473
508
108600 : "Project Zomboid" ,
474
509
944330 : "Hunt and Snare" ,
475
510
294100 : "Rimworld" ,
476
- 400750 : "Call to Arms - Gates of Hell: Ostfront"
511
+ 400750 : "Call to Arms - Gates of Hell: Ostfront" ,
512
+ 824270 : "KovaaK's" ,
513
+ 4000 : "Garry's Mod" ,
514
+ 1118200 : "People Playground" ,
515
+ 636480 : "Ravenfield"
477
516
}
478
517
479
518
# Check if the stormworks_config.ini exists else create it
@@ -484,8 +523,6 @@ def check_config(cfg):
484
523
cfg .set ('Default' , 'ModsPath' , 'insert-path-here' )
485
524
cfg .set ('Default' , '# if proxies should be scraped and used' , '' )
486
525
cfg .set ('Default' , 'Proxies' , 'yes' )
487
- cfg .set ('Default' , '# Seconds Wait time for each request (Default 5)' , '' )
488
- cfg .set ('Default' , 'WaitSeconds' , '5' )
489
526
cfg .set ('Default' , '# Randomize User Agent' , '' )
490
527
cfg .set ('Default' , 'RandomUserAgent' , 'yes' )
491
528
cfg .set ('Default' , '# Request Timeout' , '' )
@@ -498,6 +535,29 @@ def check_config(cfg):
498
535
sys .exit (0 )
499
536
config (cfg )
500
537
538
+ # Checks for a global app config
539
+ def app_cfg_checker (cfg ):
540
+ if not os .path .exists ("configs/app_config.ini" ):
541
+ cfg .add_section ('Default' )
542
+ cfg .set ('Default' , '# Check if an update is available on each startup' , '' )
543
+ cfg .set ('Default' , 'UpdatesChecker' , 'yes' )
544
+ cfg .set ('Default' , '# Automatically Write Downloaded mods to a modlist' , '' )
545
+ cfg .set ('Default' , 'MakeModlist' , 'yes' )
546
+ with open (r"configs/app_config.ini" , 'w' ) as configfile :
547
+ cfg .write (configfile )
548
+ configfile .close ()
549
+ print ("New App Config file was generated! Please configure it and then start the bot again" )
550
+ sleep (5 )
551
+ sys .exit (0 )
552
+ else :
553
+ configFilePath = "configs/app_config.ini"
554
+ cfg .read (configFilePath )
555
+ global check_for_updates
556
+ check_for_updates = cfg .get ('Default' , 'UpdatesChecker' )
557
+ global create_mod_list
558
+ create_mod_list = cfg .get ('Default' , 'MakeModlist' )
559
+ update_checker ()
560
+
501
561
# scrape proxies from a given destination
502
562
def proxy_scraper (cfg ):
503
563
proxy_source = random .choice (proxy_source_list )
@@ -510,9 +570,10 @@ def proxy_scraper(cfg):
510
570
game_selection (cfg )
511
571
512
572
if __name__ == '__main__' :
513
- update_checker ( )
573
+ app_cfg_checker ( cfg )
514
574
515
575
# Credits
516
576
#
517
577
# h110m - Helping and explaining on how to add a fancy download bar
578
+ # Firecracker - Helping me solve a stupid issue that took longer than it should to solve. I'm sorry again
518
579
#
0 commit comments