Playlist plexapi.playlist

class plexapi.playlist.Playlist(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexPartialObject, plexapi.base.Playable, plexapi.mixins.ArtMixin, plexapi.mixins.PosterMixin, plexapi.mixins.SmartFilterMixin

Represents a single Playlist.

Variables
  • TAG (str) – ‘Playlist’

  • TYPE (str) – ‘playlist’

  • addedAt (datetime) – Datetime the playlist was added to the server.

  • allowSync (bool) – True if you allow syncing playlists.

  • composite (str) – URL to composite image (/playlist/<ratingKey>/composite/<compositeid>)

  • content (str) – The filter URI string for smart playlists.

  • duration (int) – Duration of the playlist in milliseconds.

  • durationInSeconds (int) – Duration of the playlist in seconds.

  • fields (List<Field>) – List of field objects.

  • guid (str) – Plex GUID for the playlist (com.plexapp.agents.none://XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX).

  • icon (str) – Icon URI string for smart playlists.

  • key (str) – API URL (/playlist/<ratingkey>).

  • leafCount (int) – Number of items in the playlist view.

  • playlistType (str) – ‘audio’, ‘video’, or ‘photo’

  • ratingKey (int) – Unique key identifying the playlist.

  • smart (bool) – True if the playlist is a smart playlist.

  • summary (str) – Summary of the playlist.

  • title (str) – Name of the playlist.

  • type (str) – ‘playlist’

  • updatedAt (datatime) – Datetime the playlist was updated.

property thumb

Alias to self.composite.

property metadataType

Returns the type of metadata in the playlist (movie, track, or photo).

property isVideo

Returns True if this is a video playlist.

property isAudio

Returns True if this is an audio playlist.

property isPhoto

Returns True if this is a photo playlist.

filters()[source]

Returns the search filter dict for smart playlist. The filter dict be passed back into search() to get the list of items.

section()[source]

Returns the LibrarySection this smart playlist belongs to.

Raises
item(title)[source]

Returns the item in the playlist that matches the specified title.

Parameters

title (str) – Title of the item to return.

Raises

plexapi.exceptions.NotFound – When the item is not found in the playlist.

items()[source]

Returns a list of all items in the playlist.

get(title)[source]

Alias to item().

addItems(items)[source]

Add items to the playlist.

Parameters

items (List) – List of Audio, Video, or Photo objects to be added to the playlist.

Raises

plexapi.exceptions.BadRequest – When trying to add items to a smart playlist.

removeItems(items)[source]

Remove items from the playlist.

Parameters

items (List) – List of Audio, Video, or Photo objects to be removed from the playlist.

Raises
moveItem(item, after=None)[source]

Move an item to a new position in the playlist.

Parameters
  • items (obj) – Audio, Video, or Photo objects to be moved in the playlist.

  • after (obj) – Audio, Video, or Photo objects to move the item after in the playlist.

Raises
updateFilters(limit=None, sort=None, filters=None, **kwargs)[source]

Update the filters for a smart playlist.

Parameters
  • limit (int) – Limit the number of items in the playlist.

  • sort (str or list, optional) – A string of comma separated sort fields or a list of sort fields in the format column:dir. See search() for more info.

  • filters (dict) – A dictionary of advanced filters. See search() for more info.

  • **kwargs (dict) – Additional custom filters to apply to the search results. See search() for more info.

Raises

plexapi.exceptions.BadRequest – When trying update filters for a regular playlist.

edit(title=None, summary=None)[source]

Edit the playlist.

Parameters
  • title (str, optional) – The title of the playlist.

  • summary (str, optional) – The summary of the playlist.

delete()[source]

Delete the playlist.

playQueue(*args, **kwargs)[source]

Returns a new PlayQueue from the playlist.

classmethod create(server, title, section=None, items=None, smart=False, limit=None, libtype=None, sort=None, filters=None, **kwargs)[source]

Create a playlist.

Parameters
  • server (PlexServer) – Server to create the playlist on.

  • title (str) – Title of the playlist.

  • section (LibrarySection, str) – Smart playlists only, the library section to create the playlist in.

  • items (List) – Regular playlists only, list of Audio, Video, or Photo objects to be added to the playlist.

  • smart (bool) – True to create a smart playlist. Default False.

  • limit (int) – Smart playlists only, limit the number of items in the playlist.

  • libtype (str) – Smart playlists only, the specific type of content to filter (movie, show, season, episode, artist, album, track, photoalbum, photo).

  • sort (str or list, optional) – Smart playlists only, a string of comma separated sort fields or a list of sort fields in the format column:dir. See search() for more info.

  • filters (dict) – Smart playlists only, a dictionary of advanced filters. See search() for more info.

  • **kwargs (dict) – Smart playlists only, additional custom filters to apply to the search results. See search() for more info.

Raises
Returns

A new instance of the created Playlist.

Return type

Playlist

copyToUser(user)[source]

Copy playlist to another user account.

Parameters

user (str) – Username, email or user id of the user to copy the playlist to.

sync(videoQuality=None, photoResolution=None, audioBitrate=None, client=None, clientId=None, limit=None, unwatched=False, title=None)[source]

Add the playlist as a sync item for the specified device. See sync() for possible exceptions.

Parameters
  • videoQuality (int) – idx of quality of the video, one of VIDEO_QUALITY_* values defined in sync module. Used only when playlist contains video.

  • photoResolution (str) – maximum allowed resolution for synchronized photos, see PHOTO_QUALITY_* values in the module sync. Used only when playlist contains photos.

  • audioBitrate (int) – maximum bitrate for synchronized music, better use one of MUSIC_BITRATE_* values from the module sync. Used only when playlist contains audio.

  • client (MyPlexDevice) – sync destination, see sync().

  • clientId (str) – sync destination, see sync().

  • limit (int) – maximum count of items to sync, unlimited if None.

  • unwatched (bool) – if True watched videos wouldn’t be synced.

  • title (str) – descriptive title for the new SyncItem, if empty the value would be generated from metadata of current photo.

Raises
  • BadRequest – When playlist is not allowed to sync.

  • Unsupported – When playlist content is unsupported.

Returns

A new instance of the created sync item.

Return type

SyncItem