Added support for related artists

This commit is contained in:
Paul Lamere
2014-07-07 17:25:19 +02:00
parent 75a3779779
commit 1c1b84c1fa
4 changed files with 40 additions and 1 deletions

26
examples/show_related.py Normal file
View File

@@ -0,0 +1,26 @@
# shows related artists for the given seed artist
import spotipy
import sys
import pprint
if len(sys.argv) > 1:
artist_name = sys.argv[1]
else:
artist_name = 'weezer'
sp = spotipy.Spotify()
result = sp.search(q='artist:' + artist_name, type='artist')
try:
name = result['artists']['items'][0]['name']
uri = result['artists']['items'][0]['uri']
related = sp.artist_related_artists(uri)
print 'related artists for', name
for artist in related['artists']:
print ' ', artist['name']
except:
raise
print "usage show_related.py [artist-name]"