Track subsystem

The Track class

class spotify.Track

Track objects

album()
Return type:Album
Returns:The album of this track.
artists()
Return type:List of Artist
Returns:The artists who performed on this track.
availability()
Return type:integer
Returns:The availability status of this track.
Possible values:
  • 0: Track is not available
  • 1: Track is available and can be played
  • 2: Track can not be streamed using this account
  • 3: Track not available on artist’s request
disc()
Return type:int
Returns:The disc number of this track.

Note

This function returns valid data only for tracks appearing in a browse artist or browse album result (otherwise returns 0).

duration()
Return type:int
Returns:The duration of this track, in milliseconds.
error()
Return type:int
Returns:An error code associated with this track. For example if it could not load.
index()
Return type:int
Returns:The position of this track on its disc.

Note

This function returns valid data only for tracks appearing in a browse artist or browse album result (otherwise returns 0).

is_autolinked()
Return type:int
Returns:whether this track is linked to another track

If the application wants to play this track, it has to call playable() on the track to obtain the linked track.

is_loaded()
Return type:int
Returns:Load status for this track.

Note

If the track is not loaded yet, all other functions operating on the track return default values.

is_local()
Return type:bool
Returns:True if track is a local file.

Note

The track must be loaded or this function will always return False.

name()
Return type:String
Returns:The name of this track.
playable()
Return type:Track
Returns:the playable track for this track

When calling this method on a linked track, returns the linked track. On a non-linked track, returns the track itself.

popularity()
Return type:int
Returns:The popularity of this track.
starred(session[, set])
Parameters:
  • session (Session) – The current session.
  • set (bool) – If given, set the starred status of the track.
Return type:

bool

Returns:

Whether the track is starred or not.