Created
January 22, 2013 14:32
-
-
Save davidhalter/4595055 to your computer and use it in GitHub Desktop.
download grooveshark favorites and song collection (with library).
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
#!/usr/bin/env python | |
import os | |
import json | |
import grooveshark | |
client = grooveshark.Client() | |
client.init() | |
def update(check_favorites=False): | |
user_id = 6494265 | |
if check_favorites: | |
collection = client.favorites(user_id) | |
dir = '~/Music/favorites' | |
else: | |
collection = client.collection(user_id) | |
dir = '~/Music/collection' | |
dir = os.path.expanduser(dir) | |
try: | |
os.makedirs(dir) | |
except OSError: # if the directory already exists | |
pass | |
try: | |
with open(dir + '/grooveshark.json') as f: | |
index = json.load(f) | |
except IOError: # if the file doesn't yet exist | |
index = {} | |
def writeout(): | |
with open(dir + '/grooveshark.json', 'w') as f: | |
json.dump(index, f) | |
print('Sum: ', len(collection)) | |
for song in collection: | |
print(song) | |
if song.id not in index: | |
song.download(dir) | |
content = song.export() | |
index[content['id']] = content | |
del content['id'] | |
# always write out after every song, so that no information can be lost | |
writeout() | |
update(True) | |
update(False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you tell me will this work now that grooveshark has shut down? Also if so how do I run this, I see it is a python file but I'm not sure how to run the file, thank you!