How can I make a script to restore my Grooveshark playlists now that the service has been disabled?
2 answers
I created a script that will try to find all the playlists made by the user and load them into the output directory as CSV files. This is done in Python.
- You should just pass your username as a parameter to the script (i.e.
python pysharkbackup.py "my_user_name"
). Your email address should also work (the one you used to sign up for Grooveshark). - The output directory is by default set 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']])
+17
source to share
You can access some information left in your browser by specifying the localStorage variable.
- Go to grooveshark.com
- Open developer tools (right click -> Inspect Element)
- Go to Resources -> LocalStorage -> grooveshark.com
- Look for library variables: recentListens, library and storedQueue
- Parse these variables to extract your songs.
Can't give your playlists, but it can help get some of your collections.
+5
source to share