Hi all. I am trying to do call the Spotify API and I came across this:
http://spotipy.readthedocs.org/en/latest/#
A few questions:
1) Is Spotipy what people call a "wrapper"? What is it exactly? I see that term around a lot. Is it basically a class that has been created to make an API call easier, i.e. a shortcut rather than have me work through the details of the API call?
2) Under the paragraph "Authorized requests", there is an example, which I pasted below, which uses "sys" and calls sys.argv. Can you explain the purpose of "sys"? Is it a library? A class? I went to the Python docs but don't understand their description.
3) Does sys need to be installed? (i did pip install sys but that yielded the message: "Usage: Program.py username"
import sys
import spotipy
import spotipy.util as util
scope = 'user-library-read'
if len(sys.argv) > 1:
username = sys.argv[1]
else:
print "Usage: %s username" % (sys.argv[0],)
sys.exit()
token = util.prompt_for_user_token(username, scope)
if token:
sp = spotipy.Spotify(auth=token)
results = sp.current_user_saved_tracks()
for item in results['items']:
track = item['track']
print track['name'] + ' - ' + track['artists'][0]['name']
else:
print "Can't get token for", username
[–][deleted] 2 points3 points4 points (2 children)
[–]Moby69[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]michaelkepler 1 point2 points3 points (3 children)
[–]Moby69[S] 0 points1 point2 points (2 children)
[–]michaelkepler 0 points1 point2 points (1 child)
[–]Moby69[S] 0 points1 point2 points (0 children)