现在该服务已关闭,如何制作一个脚本来恢复我的Grooveshark播放列表?

时间:2021-11-05 07:16:35

The Grooveshark music streaming service has been shut down without previous notification. I had many playlists that I would like to recover (playlists I made over several years).

Grooveshark音乐流媒体服务已被关闭,恕不另行通知。我有很多我想要恢复的播放列表(我多年来制作的播放列表)。

Is there any way I could recover them? A script or something automated would be awesome.

有什么方法可以恢复它们吗?脚本或自动化的东西会很棒。

2 个解决方案

#1


17  

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. :-)

自这个答案发布以来已经过去了三年,似乎这个剧本不再适用了。如果您仍然需要恢复旧的Grooveshark播放列表,则可能不再可能。祝你好运,如果你找到办法,可以在这里分享!我很乐意接受你的回答。 :-)


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.

我创建了一个脚本,它将尝试查找用户创建的所有播放列表,并将它们作为CSV文件下载到输出目录中。它是用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).
  • 您必须将您的用户名作为参数传递给脚本(即p​​ython pysharkbackup.py“my_user_name”)。您的电子邮件地址也应该正常工作(您在Grooveshark中注册时使用的地址)。
  • The output directory is set by default to ./pysharkbackup_$USERNAME.
  • 输出目录默认设置为./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']])

#2


5  

You can access some information left in your browser by checking the localStorage variable.

您可以通过检查localStorage变量来访问浏览器中剩余的一些信息。

  1. Go to grooveshark.com
  2. 去groovehark.com
  3. Open dev tools (Right click -> Inspect Element)
  4. 打开开发工具(右键单击 - >检查元素)
  5. Go to Resources -> LocalStorage -> grooveshark.com
  6. 转到资源 - > LocalStorage - > grooveshark.com
  7. Look for library variables: recentListens, library and storedQueue
  8. 查找库变量:recentListens,library和storedQueue
  9. Parse those variables to extract your songs
  10. 解析这些变量以提取歌曲

Might not give your playlists, but can help retrieving some of your collection.

可能不会给你的播放列表,但可以帮助检索你的一些收藏。

#1


17  

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. :-)

自这个答案发布以来已经过去了三年,似乎这个剧本不再适用了。如果您仍然需要恢复旧的Grooveshark播放列表,则可能不再可能。祝你好运,如果你找到办法,可以在这里分享!我很乐意接受你的回答。 :-)


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.

我创建了一个脚本,它将尝试查找用户创建的所有播放列表,并将它们作为CSV文件下载到输出目录中。它是用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).
  • 您必须将您的用户名作为参数传递给脚本(即p​​ython pysharkbackup.py“my_user_name”)。您的电子邮件地址也应该正常工作(您在Grooveshark中注册时使用的地址)。
  • The output directory is set by default to ./pysharkbackup_$USERNAME.
  • 输出目录默认设置为./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']])

#2


5  

You can access some information left in your browser by checking the localStorage variable.

您可以通过检查localStorage变量来访问浏览器中剩余的一些信息。

  1. Go to grooveshark.com
  2. 去groovehark.com
  3. Open dev tools (Right click -> Inspect Element)
  4. 打开开发工具(右键单击 - >检查元素)
  5. Go to Resources -> LocalStorage -> grooveshark.com
  6. 转到资源 - > LocalStorage - > grooveshark.com
  7. Look for library variables: recentListens, library and storedQueue
  8. 查找库变量:recentListens,library和storedQueue
  9. Parse those variables to extract your songs
  10. 解析这些变量以提取歌曲

Might not give your playlists, but can help retrieving some of your collection.

可能不会给你的播放列表,但可以帮助检索你的一些收藏。