mirror of
https://github.com/c0de-archive/spotipy.git
synced 2024-11-05 07:27:47 +00:00
2827591b9d
Spotify's Web API has renamed the `playlist-modify` scope to `playlist-modify-public` to better describe what it allows. Even though the old one will be supported for some time, the new one is the preferred way to go.
29 lines
624 B
Python
29 lines
624 B
Python
|
|
# Adds tracks to a playlist
|
|
|
|
import pprint
|
|
import sys
|
|
|
|
import spotipy
|
|
import spotipy.oauth2 as oauth2
|
|
import util
|
|
|
|
if len(sys.argv) > 3:
|
|
username = sys.argv[1]
|
|
playlist_id = sys.argv[2]
|
|
track_ids = sys.argv[3:]
|
|
else:
|
|
print "Usage: %s username playlist_id track_id ..." % (sys.argv[0],)
|
|
sys.exit()
|
|
|
|
scope = 'playlist-modify-public'
|
|
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)
|
|
pprint.pprint(results)
|
|
else:
|
|
print "Can't get token for", username
|