Skip to content

Instantly share code, notes, and snippets.

@NeuroWinter
Created February 23, 2017 07:51
Show Gist options
  • Save NeuroWinter/5d346811a113a41888242a0acc12e903 to your computer and use it in GitHub Desktop.
Save NeuroWinter/5d346811a113a41888242a0acc12e903 to your computer and use it in GitHub Desktop.
beets to WM
import os
import json
def getArtist(releaseFile):
with open(dirpath + '/' + file) as data_file:
artist = str(data['group']['musicInfo']['artists'][1]['name'])
return artist
def getAlbum(releaseFile):
with open(dirpath + '/' + file) as data_file:
album = str(data['group']['name'])
return album
for (dirpath, dirnames, filenames) in os.walk("/home/neuro/UUI/"):
for file in os.listdir(dirpath):
if file.endswith("2.txt"):
with open(dirpath + '/' + file) as data_file:
try:
data = json.load(data_file)
# artist = str(data['group']['musicInfo']['artists'][0][1])
# artist = str(data['group']['musicInfo']['artists'][1]['name'])
# len(data['group']['musicInfo']['artists'])
# album = str(data['group']['name'])
print getArtist(data) + " " + getAlbum(data)
except :
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment