Last active
April 20, 2023 09:31
-
-
Save damp11113/edf6041a8d7ae88eb1bac2608ecd26e9 to your computer and use it in GitHub Desktop.
Minecraft Sounds Extractor python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
import shutil | |
# ---------------- setting here -------------------- | |
extracted_path = <extracted folder> | |
objects_path = <objects folder> | |
index_json = <index file ex 1.19.json> | |
# --------------------------------------------------- | |
data = json.load(open(index_json, 'r', encoding="utf-8"))["objects"] | |
objectspath = os.path.dirname(objects_path) | |
for key, value in data.items(): | |
if str(key) == "minecraft/sounds.json": continue | |
if str(key).startswith('minecraft/sounds'): | |
hash = value['hash'] | |
caf = str(key).split('minecraft/sounds/')[1] | |
for root, dirs, files in os.walk(objectspath): | |
for file in files: | |
if file == hash: | |
filename = caf.split('/')[-1] | |
cpath = caf.split(filename)[0] | |
shutil.copy(root + '/' + str(file), extracted_path) | |
if not os.path.exists(extracted_path + '/' + cpath): | |
os.makedirs(extracted_path + '/' + cpath) | |
os.rename(extracted_path + '/' + hash, extracted_path + '/' + cpath + filename) | |
print(root + '/' + str(file) + " ---> " + extracted_path + '/' + str(file) + " ---> " + extracted_path + "/" + cpath + filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment