diff --git a/hlna.py b/hlna.py index dc3618a..0c0aff1 100755 --- a/hlna.py +++ b/hlna.py @@ -456,35 +456,31 @@ def modinstall(g, m): def modextract(id_mod, id_game_workshop): - dir_steam_workshop = f"{dir_workshop_ark}/content/{id_game_workshop}/{id_mod}/WindowsNoEditor/" - dir_ark_mods = f"{dir_mods_ark}{id_mod}" + dir_steam_workshop = f"{dir_workshop_ark}/content/{id_game_workshop}/{id_mod}/WindowsNoEditor" + dir_ark_mods = f"{dir_mods_ark}/{id_mod}" dir_extract = dir_ark_mods if id_mod == "111111111": return - for dirpath, dirnames, filenames in os.walk(dir_steam_workshop): - for dname in dirnames: - os.makedirs(os.path.join(dir_extract, os.path.relpath(os.path.join(dirpath, dname), dir_steam_workshop)), exist_ok=True) - if not os.path.isdir(os.path.join(dir_steam_workshop, dname)): - shutil.rmtree(os.path.join(dir_extract, os.path.relpath(os.path.join(dirpath, dname), dir_steam_workshop))) + try: + for curdir, subdirs, files in os.walk(os.path.join(dir_steam_workshop)): + for file in files: + name, ext = os.path.splitext(file) + if ext == ".z": + src = os.path.join(curdir, file) + dst = os.path.join(curdir, name) + uncompressed = os.path.join(curdir, file + ".uncompressed_size") + unpack(src, dst) + print("[+] Extracted " + file) + os.remove(src) + if os.path.isfile(uncompressed): + os.remove(uncompressed) + except (UnpackException, SignatureUnpackException, CorruptUnpackException) as e: + print("[x] Unpacking .z files failed, aborting mod install") + return False - try: - for curdir, subdirs, files in os.walk(os.path.join(dir_steam_workshop)): - for file in files: - name, ext = os.path.splitext(file) - if ext == ".z": - src = os.path.join(curdir, file) - dst = os.path.join(dir_extract, subdirs, name) - uncompressed = os.path.join(curdir, file + ".uncompressed_size") - unpack(src, dst) - print("[+] Extracted " + file) - os.remove(src) - if os.path.isfile(uncompressed): - os.remove(uncompressed) - except (UnpackException, SignatureUnpackException, CorruptUnpackException) as e: - print("[x] Unpacking .z files failed, aborting mod install") - return False + os.system(f"mv {dir_steam_workshop} {dir_mods_ark}") modname = subprocess.check_output(['curl', '-s', 'https://steamcommunity.com/sharedfiles/filedetails/?id={}'.format(id_mod)]).decode('utf-8') modname = re.search(r'