Images

class spotify.Image(session, uri=None, sp_image=None, add_ref=True, callback=None)[source]

A Spotify image.

You can get images from Album.cover(), Artist.portrait(), Playlist.image(), or you can create an Image yourself from a Spotify URI:

>>> session = spotify.Session()
# ...
>>> image = session.get_image(
...     'spotify:image:a0bdcbe11b5cd126968e519b5ed1050b0e8183d0')
>>> image.load().data_uri[:50]
u'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEBLAEsAAD'

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.

loaded_event = None

threading.Event that is set when the image is loaded.

is_loaded

Whether the image’s data is loaded.

error

An ErrorType associated with the image.

Check to see if there was problems loading the image.

load(timeout=None)[source]

Block until the image’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.

format

The ImageFormat of the image.

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

data

The raw image data as a bytestring.

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

data_uri

The raw image data as a data: URI.

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

A Link to the image.

class spotify.ImageFormat[source]
JPEG = <ImageFormat.JPEG: 0>
UNKNOWN = <ImageFormat.UNKNOWN: -1>
class spotify.ImageSize[source]
LARGE = <ImageSize.LARGE: 2>
NORMAL = <ImageSize.NORMAL: 0>
SMALL = <ImageSize.SMALL: 1>