既然服务已关闭,我该如何制作脚本来恢复我的 Grooveshark 播放列表?
How can I make a script to recover my Grooveshark playlists now that the service has been shut down?
Grooveshark 音乐流媒体服务已关闭,恕不另行通知。我有很多想要恢复的播放列表(我制作了几年的播放列表)。
有什么方法可以恢复它们吗?脚本或自动化的东西会很棒。
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. :-)
我制作了一个脚本,它会尝试查找用户制作的所有播放列表,并将它们作为 CSV 文件下载到输出目录中。它是在 Python.
中制作的
- 您必须将您的用户名作为参数传递给脚本(即
python pysharkbackup.py "my_user_name"
)。您的电子邮件地址也应该有效(您在 Grooveshark 中注册时使用的那个)。
- 输出目录默认设置为
./pysharkbackup_$USERNAME
。
这是脚本:
#!/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']])
您可以通过检查 localStorage 变量来访问留在浏览器中的一些信息。
- 转到grooveshark.com
- 打开开发工具(右键单击 -> 检查元素)
- 转到资源 -> LocalStorage -> grooveshark.com
- 查找库变量:recentListens、library 和 storedQueue
- 解析这些变量以提取您的歌曲
可能不会提供您的播放列表,但可以帮助检索您的一些 collection。
Grooveshark 音乐流媒体服务已关闭,恕不另行通知。我有很多想要恢复的播放列表(我制作了几年的播放列表)。
有什么方法可以恢复它们吗?脚本或自动化的东西会很棒。
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. :-)
我制作了一个脚本,它会尝试查找用户制作的所有播放列表,并将它们作为 CSV 文件下载到输出目录中。它是在 Python.
中制作的- 您必须将您的用户名作为参数传递给脚本(即
python pysharkbackup.py "my_user_name"
)。您的电子邮件地址也应该有效(您在 Grooveshark 中注册时使用的那个)。 - 输出目录默认设置为
./pysharkbackup_$USERNAME
。
这是脚本:
#!/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']])
您可以通过检查 localStorage 变量来访问留在浏览器中的一些信息。
- 转到grooveshark.com
- 打开开发工具(右键单击 -> 检查元素)
- 转到资源 -> LocalStorage -> grooveshark.com
- 查找库变量:recentListens、library 和 storedQueue
- 解析这些变量以提取您的歌曲
可能不会提供您的播放列表,但可以帮助检索您的一些 collection。