Skip to content

Instantly share code, notes, and snippets.

@davidhalter
Created January 22, 2013 14:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidhalter/4595055 to your computer and use it in GitHub Desktop.
Save davidhalter/4595055 to your computer and use it in GitHub Desktop.
download grooveshark favorites and song collection (with library).
#!/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)
@guacamoleisgreat
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment