Artists

class spotify.Artist(session, uri=None, sp_artist=None, add_ref=True)[source]

A Spotify artist.

You can get artists from tracks and albums, or you can create an Artist yourself from a Spotify URI:

>>> session = spotify.Session()
# ...
>>> artist = session.get_artist(
...     'spotify:artist:22xRIphSN7IkPVbErICu7s')
>>> artist.load().name
u'Rob Dougan'
name

The artist’s name.

Will always return None if the artist isn’t loaded.

is_loaded

Whether the artist’s data is loaded.

load(timeout=None)[source]

Block until the artist’s data is loaded.

After timeout seconds with no results Timeout is raised. If timeout is None the default timeout is used.

The method returns self to allow for chaining of calls.

portrait(image_size=None, callback=None)[source]

The artist’s portrait Image.

image_size is an ImageSize value, by default ImageSize.NORMAL.

If callback isn’t None, it is expected to be a callable that accepts a single argument, an Image instance, when the image is done loading.

Will always return None if the artist isn’t loaded or the artist has no portrait.

A Link to the artist’s portrait.

image_size is an ImageSize value, by default ImageSize.NORMAL.

This is equivalent with artist.portrait(image_size).link, except that this method does not need to create the artist portrait image object to create a link to it.

A Link to the artist.

browse(type=None, callback=None)[source]

Get an ArtistBrowser for the artist.

If type is None, it defaults to ArtistBrowserType.FULL.

If callback isn’t None, it is expected to be a callable that accepts a single argument, an ArtistBrowser instance, when the browser is done loading.

Can be created without the artist being loaded.

class spotify.ArtistBrowser(session, artist=None, type=None, callback=None, sp_artistbrowse=None, add_ref=True)[source]

An artist browser for a Spotify artist.

You can get an artist browser from any Artist instance by calling Artist.browse():

>>> session = spotify.Session()
# ...
>>> artist = session.get_artist(
...     'spotify:artist:421vyBBkhgRAOz4cYPvrZJ')
>>> browser = artist.browse()
>>> browser.load()
>>> len(browser.albums)
7
loaded_event = None

threading.Event that is set when the artist browser is loaded.

is_loaded

Whether the artist browser’s data is loaded.

load(timeout=None)[source]

Block until the artist browser’s data is loaded.

After timeout seconds with no results Timeout is raised. If timeout is None the default timeout is used.

The method returns self to allow for chaining of calls.

error

An ErrorType associated with the artist browser.

Check to see if there was problems creating the artist browser.

backend_request_duration

The time in ms that was spent waiting for the Spotify backend to create the artist browser.

Returns -1 if the request was served from local cache. Returns None if the artist browser isn’t loaded yet.

artist

Get the Artist the browser is for.

Will always return None if the artist browser isn’t loaded.

portraits(callback=None)[source]

The artist’s portraits.

Due to limitations in libspotify’s API you can’t specify the ImageSize of these images.

If callback isn’t None, it is expected to be a callable that accepts a single argument, an Image instance, when the image is done loading. The callable will be called once for each portrait.

Will always return an empty list if the artist browser isn’t loaded.

tracks

The artist’s tracks.

Will be an empty list if the browser was created with a type of ArtistBrowserType.NO_TRACKS or ArtistBrowserType.NO_ALBUMS.

Will always return an empty list if the artist browser isn’t loaded.

tophit_tracks

The artist’s top hit tracks.

Will always return an empty list if the artist browser isn’t loaded.

albums

The artist’s albums.

Will be an empty list if the browser was created with a type of ArtistBrowserType.NO_ALBUMS.

Will always return an empty list if the artist browser isn’t loaded.

similar_artists

The artist’s similar artists.

Will always return an empty list if the artist browser isn’t loaded.

biography

A biography of the artist.

Will always return an empty string if the artist browser isn’t loaded.

class spotify.ArtistBrowserType[source]
FULL = <ArtistBrowserType.FULL: 0>
NO_ALBUMS = <ArtistBrowserType.NO_ALBUMS: 2>
NO_TRACKS = <ArtistBrowserType.NO_TRACKS: 1>