mirror of
https://github.com/c0de-archive/spotipy.git
synced 2025-07-30 14:00:18 +00:00
Merge pull request #16 from thelinmichael/add-yourmusic-contains-track-endpoint
Add support for checking if a user's Your Music library contains a track
This commit is contained in:
25
examples/contains_a_saved_track.py
Normal file
25
examples/contains_a_saved_track.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import pprint
|
||||
import sys
|
||||
|
||||
import spotipy
|
||||
import spotipy.oauth2 as oauth2
|
||||
import util
|
||||
|
||||
scope = 'user-library-read'
|
||||
|
||||
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_contains(ids=tids)
|
||||
pprint.pprint(results)
|
||||
else:
|
||||
print "Can't get token for", username
|
Reference in New Issue
Block a user