gpt4 book ai didi

python - 既然服务已关闭,我该如何制作脚本来恢复我的 Grooveshark 播放列表?

转载 作者:太空狗 更新时间:2023-10-30 01:40:22 24 4
gpt4 key购买 nike

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']])

关于python - 既然服务已关闭,我该如何制作脚本来恢复我的 Grooveshark 播放列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30124541/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com