Skip to content

Instantly share code, notes, and snippets.

@LewisGet
Created February 14, 2021 15:09
Show Gist options
  • Save LewisGet/5f7cfec90c0e5f1a7c031131064385aa to your computer and use it in GitHub Desktop.
Save LewisGet/5f7cfec90c0e5f1a7c031131064385aa to your computer and use it in GitHub Desktop.
import shutil
import json
import os
with open(os.path.sep.join(["indexes", "1.12.json"])) as json_file:
data = json.load(json_file)
for k, v in data['objects'].items():
name = os.path.sep.join((os.path.splitext(k)[0]).split("/"))
path = os.path.sep.join(os.path.dirname(name).split("/"))
ext = os.path.splitext(k)[1]
if os.path.splitext(k)[1] == ".ogg":
os.makedirs(path, exist_ok=True)
find_dir = "".join(list(v['hash'])[0:2])
hash_file = os.path.sep.join(["objects", find_dir, v['hash']])
shutil.copy(hash_file, os.path.sep.join([name + ext]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment