Tracks¶
-
class
spotify.
Track
(session, uri=None, sp_track=None, add_ref=True)[source]¶ A Spotify track.
You can get tracks from playlists or albums, or you can create a
Track
yourself from a Spotify URI:>>> session = spotify.Session() # ... >>> track = session.get_track('spotify:track:2Foc5Q5nqNiosCNqttzHof') >>> track.load().name u'Get Lucky'
-
property
is_loaded
¶ Whether the track’s data is loaded.
-
property
error
¶ An
ErrorType
associated with the track.Check to see if there was problems loading the track.
-
load
(timeout=None)[source]¶ Block until the track’s data is loaded.
After
timeout
seconds with no resultsTimeout
is raised. Iftimeout
isNone
the default timeout is used.The method returns
self
to allow for chaining of calls.
-
property
offline_status
¶ The
TrackOfflineStatus
of the track.The
metadata_updated
callback is called when the offline status changes.Will always return
None
if the track isn’t loaded.
-
property
availability
¶ The
TrackAvailability
of the track.Will always return
None
if the track isn’t loaded.
-
property
is_local
¶ Whether the track is a local track.
Will always return
None
if the track isn’t loaded.
-
property
is_autolinked
¶ Whether the track is a autolinked to another track.
Will always return
None
if the track isn’t loaded.See
playable
.
-
property
playable
¶ The actual track that will be played when this track is played.
Will always return
None
if the track isn’t loaded.See
is_autolinked
.
-
property
is_placeholder
¶ Whether the track is a placeholder for a non-track object in the playlist.
To convert to the real object:
>>> session = spotify.Session() # ... >>> track = session.get_track( ... 'spotify:track:2Foc5Q5nqNiosCNqttzHof') >>> track.load() >>> track.is_placeholder True >>> track.link.type <LinkType.ARTIST: ...> >>> artist = track.link.as_artist()
Will always return
None
if the track isn’t loaded.
-
property
starred
¶ Whether the track is starred by the current user.
Set to
True
orFalse
to change.Will always be
None
if the track isn’t loaded.
-
property
artists
¶ The artists performing on the track.
Will always return an empty list if the track isn’t loaded.
-
property
album
¶ The album of the track.
Will always return
None
if the track isn’t loaded.
-
property
name
¶ The track’s name.
Will always return
None
if the track isn’t loaded.
-
property
duration
¶ The track’s duration in milliseconds.
Will always return
None
if the track isn’t loaded.
-
property
popularity
¶ The track’s popularity in the range 0-100, 0 if undefined.
Will always return
None
if the track isn’t loaded.
-
property
disc
¶ The track’s disc number. 1 or higher.
Will always return
None
if the track isn’t part of an album or artist browser.
-
property
index
¶ The track’s index number. 1 or higher.
Will always return
None
if the track isn’t part of an album or artist browser.
-
property