From 0850957700792112066efd8763f1425e5785542b Mon Sep 17 00:00:00 2001 From: Fierelier Date: Thu, 17 Jun 2021 13:02:50 +0200 Subject: [PATCH] Add tool: fix-classic-sound --- tool_fix-classic-sound.py | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tool_fix-classic-sound.py diff --git a/tool_fix-classic-sound.py b/tool_fix-classic-sound.py new file mode 100644 index 0000000..86568c2 --- /dev/null +++ b/tool_fix-classic-sound.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 +import sys + +oldexcepthook = sys.excepthook +def newexcepthook(type,value,traceback): + oldexcepthook(type,value,traceback) + input("Press ENTER to quit.") +sys.excepthook = newexcepthook + +import os +import shutil +p = os.path.join +pUp = os.path.dirname +s = False +if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): + s = os.path.realpath(sys.executable) +else: + s = os.path.realpath(__file__) +sp = pUp(s) + +import json + +def main(): + assetJson = {} + with open(p("assets","indexes","pre-1.6.json"),"r") as jsonFile: + assetJson = json.loads(jsonFile.read()) + + for asset in assetJson["objects"]: + hash = assetJson["objects"][asset]["hash"] + infile = p("assets","objects",hash[:2],hash) + outfile = p("resources",asset) + outfolder = pUp(outfile) + + if not os.path.isdir(outfolder): + os.makedirs(outfolder) + + if not os.path.isfile(outfile): + print(asset+ " ...") + shutil.copyfile(infile,outfile) + +main() \ No newline at end of file