Playlists

The Playlist class

Playlist objects are iterable: they are a list of Track objects.

class spotify.Playlist

Playlist objects.

add_tracks(position, tracks)
Parameters:
  • position (int) – where to add the tracks in the playlist
  • tracks (list of Track) – tracks to add to the playlist
add_tracks_added_callback(callback[, userdata])
Parameters:
  • callback – signature: (Playlist p, list of Track tracks, int position, Object userdata)
  • userdata – any object you would like to access in the callback
add_tracks_moved_callback(callback[, userdata])
Parameters:
  • callback – signature: (Playlist p, list of Track tracks, int new_position, Object userdata)
  • userdata – any object you would like to access in the callback
add_tracks_removed_callback(callback[, userdata])
Parameters:
  • callback – signature: (Playlist p, list of Track tracks, Object userdata)
  • userdata – any object you would like to access in the callback
add_playlist_renamed_callback(callback[, userdata])
Parameters:
  • callback – signature: (Playlist p, Object userdata)
  • userdata – any object you would like to access in the callback
add_playlist_state_changed_callback(callback[, userdata])
Parameters:
  • callback – signature: (Playlist p, Object userdata)
  • userdata – any object you would like to access in the callback

Called when state changed for a playlist.

There are three states that trigger this callback:

  • Collaboration for this playlist has been turned on or off

  • The playlist started having pending changes, or all pending

    changes have now been committed

  • The playlist started loading, or finished loading

add_playlist_update_in_progress_callback(callback[, userdata])
Parameters:
  • callback – signature: (Playlist p, bool done, Object userdata)
  • userdata – any object you would like to access in the callback

Called when a playlist is updating or is done updating.

This is called before and after a series of changes are applied to the playlist. It allows e.g. the user interface to defer updating until the entire operation is complete.

add_playlist_metadata_updated_callback(callback[, userdata])
Parameters:
  • callback – signature: (Playlist p, Object userdata)
  • userdata – any object you would like to access in the callback
add_track_created_changed_callback(callback[, userdata])
Parameters:
  • callback – signature: (Playlist p, int position, User user, int when, Object userdata)
  • userdata – any object you would like to access in the callback

user is the new user information and when is a time in seconds since the UNIX Epoch.

add_track_message_changed_callback(callback[, userdata])
Parameters:
  • callback – signature: (Playlist p, int position, unicode message, Object userdata)
  • userdata – any object you would like to access in the callback
add_track_seen_changed_callback(callback[, userdata])
Parameters:
  • callback – signature: (Playlist p, int position, bool seen, Object userdata)
  • userdata – any object you would like to access in the callback
add_description_changed_callback(callback[, userdata])
Parameters:
  • callback – signature: (Playlist p, unicode description, Object userdata)
  • userdata – any object you would like to access in the callback
add_subscribers_changed_callback(callback[, userdata])
Parameters:
  • callback – signature: (Playlist p, Object userdata)
  • userdata – any object you would like to access in the callback
add_image_changed_callback(callback[, userdata])
Parameters:
  • callback – signature: (Playlist p, str image_id, Object userdata)
  • userdata – any object you would like to access in the callback
is_collaborative()
Return type:int
Returns:collaborative status for a playlist.

Note

A playlist in collaborative state can be modifed by all users, not only the user owning the list.

is_loaded()
Return type:int
Returns:wether this playlist has been loaded by the client
name()
Return type:string
Returns:the name of the playlist.
num_subscribers()
Return type:int
Returns:The number of subscribers of this playlist
owner()
Return type:spotify.User
Returns:the owner of the playlist
rename(name)
Parameters:name (unicode) – the new name
remove_callback(callback[, userdata])

Removes the corresponding callback, userdata couple.

remove_tracks(tracks)
Parameters:tracks (list of Track) – A list of tracks to be removed from the playlist.
subscribers()
Return type:list of unicode
Returns:a list of canonical names of subscribers of this playlist.

Note

The count returned for this function may be less than those returned by num_subscribers(). Spotify does not track each user subscribed to a playlist for playlist with many (>500) subscribers.

track_create_time(index)
Parameters:index (int) – index of the track in the playlist
Return type:int
Returns:number of seconds after Unix epoch the track was added to the playlist
type()

returns 'playlist'

update_subscribers()

Ask library to update the subscription count for a playlist.

When the subscription info has been fetched from the Spotify backend the manager.SpotifyPlaylistManager.subscribers_changed() callback will be invoked. In that callback use num_subscribers() and/or subscribers() to get information about the subscribers. You can call those two functions anytime you want but the information might not be up to date in such cases

The PlaylistFolder class

class spotify.PlaylistFolder

An entry in a playlist container that is not a playlist (often folder boundaries).

id()

if type is 'folder_start', returns the id of the folder, else returns 0.

is_loaded()

returns True when the container it belongs to is loaded.

name()

if type is 'folder_start', returns the name of the folder, else returns an empty string.

type()

returns 'folder_start', 'folder_end' or 'placeholder'.

Project Versions

Table Of Contents

Previous topic

Search subsystem

Next topic

Playlist containers

This Page