2014-06-17 11:40:20 +00:00
|
|
|
|
|
|
|
# Adds tracks to a playlist
|
|
|
|
|
|
|
|
import pprint
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import spotipy
|
2014-08-14 10:39:24 +00:00
|
|
|
import spotipy.util as util
|
2014-06-17 11:40:20 +00:00
|
|
|
|
|
|
|
if len(sys.argv) > 3:
|
|
|
|
username = sys.argv[1]
|
|
|
|
playlist_id = sys.argv[2]
|
|
|
|
track_ids = sys.argv[3:]
|
|
|
|
else:
|
2015-06-05 09:07:28 +00:00
|
|
|
print("Usage: %s username playlist_id track_id ..." % (sys.argv[0],))
|
2014-06-17 11:40:20 +00:00
|
|
|
sys.exit()
|
|
|
|
|
2014-07-21 11:02:01 +00:00
|
|
|
scope = 'playlist-modify-public'
|
2014-06-17 11:40:20 +00:00
|
|
|
token = util.prompt_for_user_token(username, scope)
|
|
|
|
|
|
|
|
if token:
|
|
|
|
sp = spotipy.Spotify(auth=token)
|
|
|
|
sp.trace = False
|
|
|
|
results = sp.user_playlist_add_tracks(username, playlist_id, track_ids)
|
2015-06-05 09:07:28 +00:00
|
|
|
print(results)
|
2014-06-17 11:40:20 +00:00
|
|
|
else:
|
2015-06-05 09:07:28 +00:00
|
|
|
print("Can't get token for", username)
|