2014-06-16 17:30:57 +00:00
|
|
|
# Creates a playlist for a user
|
|
|
|
|
|
|
|
import pprint
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
import spotipy
|
2014-08-14 10:39:24 +00:00
|
|
|
import spotipy.util as util
|
2014-06-16 17:30:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
if len(sys.argv) > 2:
|
|
|
|
username = sys.argv[1]
|
|
|
|
playlist_name = sys.argv[2]
|
2017-06-02 23:51:59 +00:00
|
|
|
playlist_description = sys.argv[3]
|
2014-06-16 17:30:57 +00:00
|
|
|
else:
|
2017-06-02 23:51:59 +00:00
|
|
|
print("Usage: %s username playlist-name playlist-description" % (sys.argv[0],))
|
2014-06-16 17:30:57 +00:00
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
token = util.prompt_for_user_token(username)
|
|
|
|
|
|
|
|
if token:
|
|
|
|
sp = spotipy.Spotify(auth=token)
|
|
|
|
sp.trace = False
|
2017-06-02 23:51:59 +00:00
|
|
|
playlists = sp.user_playlist_create(username, playlist_name,
|
|
|
|
playlist_description)
|
2014-06-16 17:30:57 +00:00
|
|
|
pprint.pprint(playlists)
|
|
|
|
else:
|
2015-06-05 09:07:28 +00:00
|
|
|
print("Can't get token for", username)
|