5
5
from json import load , dump
6
6
from rapidfuzz import fuzz , process
7
7
from webbrowser import open as openWeb
8
- from os import path , rename , walk , chdir
9
8
from re import IGNORECASE , compile as comp
10
9
from psutil import process_iter , NoSuchProcess
10
+ from os import path , rename , walk , chdir , listdir
11
11
from webview import create_window , start , windows as webWindows
12
12
13
13
from rodnmod .fishfinder import findWebfishing
@@ -55,11 +55,18 @@ def launchWebfishing(self, vanilla: bool = False):
55
55
def configure (self , configItem : str , configValue = None ):
56
56
configPath = "data/config.json"
57
57
if not path .exists (configPath ):
58
- default_config = {"debugging" : "debdis" }
58
+ default_config = {
59
+ "debugging" : "debdis" ,
60
+ "hlsmods" : "findhls" ,
61
+ "reelsound" : "reel" ,
62
+ "transition" : "transition" ,
63
+ "filter" : "installed" ,
64
+ "category" : "all" ,
65
+ "nsfw" : "hidensfw"
66
+ }
59
67
with open (configPath , 'w' ) as file :
60
68
dump (default_config , file , indent = 4 )
61
69
62
- # If config file exists, load it
63
70
with open (configPath ) as file :
64
71
config = load (file )
65
72
@@ -270,12 +277,12 @@ def downloadMod(self, mod: str):
270
277
if dependencyPath :
271
278
try :
272
279
with open (dependencyPath + "\\ rnmInfo.json" , "r" ) as f :
273
- mnrInfo = load (f )
280
+ rnmInfo = load (f )
274
281
except :
275
282
# cant do anything about this, probbably a mod installed via HLS.
276
- mnrInfo = {"version" : "1.0.0" }
283
+ rnmInfo = {"version" : "1.0.0" }
277
284
278
- if mnrInfo ["version" ] != dependencyVersion :
285
+ if rnmInfo ["version" ] != dependencyVersion :
279
286
download (dependencyDownload , installationPath + "\\ GDWeave\\ mods" , {"name" : dependencyName , "author" : dependencyAuthor , "version" : dependencyVersion })
280
287
281
288
else :
@@ -288,15 +295,15 @@ def downloadMod(self, mod: str):
288
295
try :
289
296
if modPath != None :
290
297
with open (modPath + "\\ rnmInfo.json" , "r" ) as f :
291
- mnrInfo = load (f )
298
+ rnmInfo = load (f )
292
299
293
- if mnrInfo ["version" ] != modVersion :
300
+ if rnmInfo ["version" ] != modVersion :
294
301
download (modDownload , installationPath + "\\ GDWeave\\ mods" , {"name" : modName , "author" : modAuthor , "version" : modVersion })
295
302
window .evaluate_js (f"notify('{ modName } has been updated successfully!', 3000)" )
296
303
else :
297
304
window .evaluate_js (f"notify('{ modName } is currently up to date!', 3000)" )
298
305
299
- except FileNotFoundError : # mnrInfo .json missing, skip version check and download mod immediately instead
306
+ except FileNotFoundError : # rnmInfo .json missing, skip version check and download mod immediately instead
300
307
window .evaluate_js (f"notify('rnmInfo.json for { modName } missing. Forcing download...', 3000)" )
301
308
download (modDownload , installationPath + "\\ GDWeave\\ mods" , {"name" : modName , "author" : modAuthor , "version" : modVersion })
302
309
@@ -330,6 +337,28 @@ def uninstallMod(self, mod: str, checkExists: bool = False):
330
337
except PermissionError :
331
338
window .evaluate_js (f"notify('Permission denied! Please close WEBFISHING first to uninstall the mod!', 3000)" )
332
339
340
+ def updateAllMods (self ):
341
+ window .evaluate_js (f"notify('Updating Mods...', 3000)" )
342
+ fpath = installationPath + "\\ GDWeave\\ mods"
343
+ folders = [entry for entry in listdir (fpath ) if path .isdir (path .join (fpath , entry ))]
344
+
345
+ for mod in folders :
346
+ try : mod = mod .split ("." )[1 ]
347
+ except IndexError : pass
348
+ _ , value = next (iter (self .searchModList (mod , "none" , "all" , "shownsfw" ).items ()))
349
+
350
+ try :
351
+ with open (f"{ fpath } \\ " + value .get ("modAuthor" ) + "." + value .get ("modName" ) + "\\ rnmInfo.json" , "r" ) as f :
352
+ modInfo = load (f )
353
+ except FileNotFoundError :
354
+ modInfo = {"version" : "null" }
355
+
356
+ if value .get ("latestVersion" ) != modInfo ["version" ]:
357
+ self .downloadMod (value .get ("modAuthor" ) + "-" + value .get ("modName" ))
358
+
359
+ window .evaluate_js (f"notify('Updated all mods!', 3000)" )
360
+
361
+
333
362
rnm = RodNMod ()
334
363
335
364
if __name__ == "__main__" :
0 commit comments