Documentation and support for Your Music methods

This commit is contained in:
Paul Lamere
2014-07-23 10:29:40 -04:00
parent 2d98c30d01
commit 1ebbac6de7
5 changed files with 68 additions and 6 deletions

View File

@@ -0,0 +1,28 @@
# Add tracks to 'Your Collection' of saved tracks
import pprint
import sys
import spotipy
import spotipy.oauth2 as oauth2
import util
scope = 'user-library-modify'
if len(sys.argv) > 2:
username = sys.argv[1]
tids = sys.argv[2:]
else:
print "Usage: %s username track-id ..." % (sys.argv[0],)
sys.exit()
token = util.prompt_for_user_token(username, scope)
if token:
sp = spotipy.Spotify(auth=token)
sp.trace = False
results = sp.current_user_saved_tracks_add(ids=tids)
pprint.pprint(results)
else:
print "Can't get token for", username

View File

@@ -0,0 +1,27 @@
# Delete a track from 'Your Collection' of saved tracks
import pprint
import sys
import spotipy
import spotipy.oauth2 as oauth2
import util
scope = 'user-library-modify'
if len(sys.argv) > 2:
username = sys.argv[1]
tids = sys.argv[2:]
else:
print "Usage: %s username track-id ..." % (sys.argv[0],)
sys.exit()
token = util.prompt_for_user_token(username, scope)
if token:
sp = spotipy.Spotify(auth=token)
sp.trace = False
results = sp.current_user_saved_tracks_delete(ids=tids)
pprint.pprint(results)
else:
print "Can't get token for", username