Update [2018-05-11]
Three years have passed since this answer was posted and it seems this script no longer works. If you are still in need to recover your old Grooveshark playlists, it might not be possible anymore. Good luck and, if you find a way to do it, share it here! I will be happy to accept your answer instead. :-)
I made a script that will try to find all the playlists made by the user and download them in an output directory as CSV files. It is made in Python.
- You must just pass your username as parameter to the script (i.e.
python pysharkbackup.py "my_user_name"
). Your email address should work as well (the one you used for registering in Grooveshark).
- The output directory is set by default to
./pysharkbackup_$USERNAME
.
Here is the script:
#!/bin/python
import os
import sys
import csv
import argparse
import requests
URI = 'http://playlist.fish/api'
description = 'Download your Grooveshark playlists as CSV.'
parser = argparse.ArgumentParser(description = description)
parser.add_argument('USER', type=str, help='Grooveshar user name')
args = parser.parse_args()
user = args.USER
with requests.Session() as session:
# Login as user
data = {'method': 'login', 'params': {'username': user}}
response = session.post(URI, json=data).json()
if not response['success']:
print('Could not login as user "%s"! (%s)' %
(user, response['result']))
sys.exit()
# Get user playlists
data = {'method': 'getplaylists'}
response = session.post(URI, json=data).json()
if not response['success']:
print('Could not get "%s" playlists! (%s)' %
(user, response['result']))
sys.exit()
# Save to CSV
playlists = response['result']
if not playlists:
print('No playlists found for user %s!' % user)
sys.exit()
path = './pysharkbackup_%s' % user
if not os.path.exists(path):
os.makedirs(path)
for p in playlists:
plid = p['id']
name = p['n']
data = {'method': 'getPlaylistSongs', 'params': {'playlistID': plid}}
response = session.post(URI, json=data).json()
if not response['success']:
print('Could not get "%s" songs! (%s)' %
(name, response['result']))
continue
playlist = response['result']
f = csv.writer(open(path + '/%s.csv' % name, 'w'))
f.writerow(['Artist', 'Album', 'Name'])
for song in playlist:
f.writerow([song['Artist'], song['Album'], song['Name']])