Created
July 6, 2022 19:47
-
-
Save apacheli/2771435cac3bdb86429d0ea478d3ec77 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const APPDATA = Deno.env.get("APPDATA"); | |
const index = await Deno.readTextFile( | |
`${APPDATA}/.minecraft/assets/indexes/1.19.json`, | |
); | |
const json = JSON.parse(index); | |
const directories = {}; | |
const promises1 = []; | |
const promises2 = []; | |
for (const filename in json.objects) { | |
if (filename.substring(filename.length - 4) !== ".ogg") { | |
continue; | |
} | |
const hash = json.objects[filename].hash; | |
const index = hash.substring(0, 2); | |
const object = `${APPDATA}/.minecraft/assets/objects/${index}/${hash}`; | |
const directory = filename.substring(0, filename.lastIndexOf("/")); | |
(directories[directory] ??= []).push({ filename, object }); | |
} | |
for (const directory in directories) { | |
promises1.push(Deno.mkdir(directory, { recursive: true })); | |
} | |
await Promise.all(promises1); | |
for (const directory in directories) { | |
for (const { filename, object } of directories[directory]) { | |
const p = Deno.readFile(object).then((x) => Deno.writeFile(filename, x)); | |
promises2.push(p); | |
} | |
} | |
await Promise.all(promises2); | |
console.log("Done."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this sucks