mirror of
https://github.com/c0de-archive/spotipy.git
synced 2024-11-04 23:17:48 +00:00
Added support for related artists
This commit is contained in:
parent
75a3779779
commit
1c1b84c1fa
@ -2,5 +2,5 @@ v1.40, June 12, 2014 -- Initial public release.
|
|||||||
v1.42, June 19, 2014 -- Removed dependency on simplejson
|
v1.42, June 19, 2014 -- Removed dependency on simplejson
|
||||||
v1.43, June 27, 2014 -- Fixed JSON handling issue
|
v1.43, June 27, 2014 -- Fixed JSON handling issue
|
||||||
v1.44, July 3, 2014 -- Added show_tracks.py exampole
|
v1.44, July 3, 2014 -- Added show_tracks.py exampole
|
||||||
v1.45, July 7, 2014 -- Don't used cache auth codes when scope changes
|
v1.45, July 7, 2014 -- Support for related artists endpoint. Don't used cache auth codes when scope changes
|
||||||
|
|
||||||
|
@ -85,3 +85,9 @@ at [paul@echonest.com](mailto:paul@echonest.com). Or just send me a pull request
|
|||||||
- 1.4.1 - 06/17/2014 - Updates to match released API
|
- 1.4.1 - 06/17/2014 - Updates to match released API
|
||||||
- 1.4.2 - 06/21/2014 - Added support for retrieving starred playlists
|
- 1.4.2 - 06/21/2014 - Added support for retrieving starred playlists
|
||||||
|
|
||||||
|
- v1.40, June 12, 2014 -- Initial public release.
|
||||||
|
- v1.42, June 19, 2014 -- Removed dependency on simplejson
|
||||||
|
- v1.43, June 27, 2014 -- Fixed JSON handling issue
|
||||||
|
- v1.44, July 3, 2014 -- Added show_tracks.py example
|
||||||
|
- v1.45, July 7, 2014 -- Support for related artists endpoint. Don't used cache auth codes when scope changes
|
||||||
|
|
||||||
|
26
examples/show_related.py
Normal file
26
examples/show_related.py
Normal 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]"
|
||||||
|
|
@ -167,6 +167,13 @@ class Spotify(object):
|
|||||||
trid = self._get_id('artist', artist_id)
|
trid = self._get_id('artist', artist_id)
|
||||||
return self.get('artists/' + trid + '/top-tracks', country=country)
|
return self.get('artists/' + trid + '/top-tracks', country=country)
|
||||||
|
|
||||||
|
def artist_related_artists(self, artist_id):
|
||||||
|
''' Get Spotify catalog information about artists similar to an identified artist. Similarity is based
|
||||||
|
on analysis of the Spotify community’s listening history.
|
||||||
|
'''
|
||||||
|
trid = self._get_id('artist', artist_id)
|
||||||
|
return self.get('artists/' + trid + '/related-artists')
|
||||||
|
|
||||||
def album(self, album_id):
|
def album(self, album_id):
|
||||||
''' returns a single album given the album's ID, URN or URL
|
''' returns a single album given the album's ID, URN or URL
|
||||||
'''
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user