This commit is contained in:
Евгений Храмов 2023-05-14 14:49:31 +03:00
parent d5647ee05c
commit 9b6098a9d6

31
hlna.py

@ -381,23 +381,22 @@ def modextract(id_mod, id_game_workshop):
for dirpath, dirnames, filenames in os.walk(mod_steam_workshop): for dirpath, dirnames, filenames in os.walk(mod_steam_workshop):
for dname in dirnames: for dname in dirnames:
os.makedirs(os.path.join(modextractdir, os.path.relpath(os.path.join(dirpath, dname), mod_steam_workshop)), exist_ok=True) os.makedirs(os.path.join(modextractdir, os.path.relpath(os.path.join(dirpath, dname), mod_steam_workshop)), exist_ok=True)
print_line(filenames)
for fname in filenames:
if not os.path.isfile(os.path.join(mod_steam_workshop, fname)) and not os.path.isfile(os.path.join(mod_steam_workshop, fname + ".z")):
os.unlink(os.path.join(modextractdir, fname))
print_line(dirnames)
for dname in dirnames:
if not os.path.isdir(os.path.join(mod_steam_workshop, dname)):
shutil.rmtree(os.path.join(modextractdir, os.path.relpath(os.path.join(dirpath, dname), mod_steam_workshop)))
for fname in filenames: for root, dirs, files in os.walk(mod_steam_workshop):
print_line(fname) for name in files:
if not os.path.isfile(os.path.join(mod_steam_workshop, fname)) and not os.path.isfile(os.path.join(mod_steam_workshop, fname + ".z")): if not (name.endswith(".z") or name.endswith(".z.uncompressed_size")):
os.unlink(os.path.join(modextractdir, fname)) srcfile = os.path.join(root, name)
dstfile = os.path.join(modextractdir, os.path.relpath(srcfile, mod_steam_workshop))
for dname in dirnames: if not os.path.isfile(dstfile) or os.path.getmtime(srcfile) > os.path.getmtime(dstfile):
if not os.path.isdir(os.path.join(mod_steam_workshop, dname)): shutil.copy2(srcfile, dstfile)
shutil.rmtree(os.path.join(modextractdir, os.path.relpath(os.path.join(dirpath, dname), mod_steam_workshop)))
for root, dirs, files in os.walk(mod_steam_workshop):
for name in files:
if not (name.endswith(".z") or name.endswith(".z.uncompressed_size")):
srcfile = os.path.join(root, name)
dstfile = os.path.join(modextractdir, os.path.relpath(srcfile, mod_steam_workshop))
if not os.path.isfile(dstfile) or os.path.getmtime(srcfile) > os.path.getmtime(dstfile):
shutil.copy2(srcfile, dstfile)
modname = subprocess.check_output(['curl', '-s', 'https://steamcommunity.com/sharedfiles/filedetails/?id={}'.format(id_mod)]).decode('utf-8') modname = subprocess.check_output(['curl', '-s', 'https://steamcommunity.com/sharedfiles/filedetails/?id={}'.format(id_mod)]).decode('utf-8')
modname = re.search(r'<div class="workshopItemTitle">(.+)</div>', modname) modname = re.search(r'<div class="workshopItemTitle">(.+)</div>', modname)