Media plexapi.media

class plexapi.media.Media(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Container object for all MediaPart objects. Provides useful data about the video or audio this media belong to such as video framerate, resolution, etc.

Variables
  • TAG (str) – ‘Media’

  • aspectRatio (float) – The aspect ratio of the media (ex: 2.35).

  • audioChannels (int) – The number of audio channels of the media (ex: 6).

  • audioCodec (str) – The audio codec of the media (ex: ac3).

  • audioProfile (str) – The audio profile of the media (ex: dts).

  • bitrate (int) – The bitrate of the media (ex: 1624).

  • container (str) – The container of the media (ex: avi).

  • duration (int) – The duration of the media in milliseconds (ex: 6990483).

  • height (int) – The height of the media in pixels (ex: 256).

  • id (int) – The unique ID for this media on the server.

  • has64bitOffsets (bool) – True if video has 64 bit offsets.

  • optimizedForStreaming (bool) – True if video is optimized for streaming.

  • parts (List<MediaPart>) – List of media part objects.

  • proxyType (int) – Equals 42 for optimized versions.

  • target (str) – The media version target name.

  • title (str) – The title of the media.

  • videoCodec (str) – The video codec of the media (ex: ac3).

  • videoFrameRate (str) – The video frame rate of the media (ex: 24p).

  • videoProfile (str) – The video profile of the media (ex: high).

  • videoResolution (str) – The video resolution of the media (ex: sd).

  • width (int) – The width of the video in pixels (ex: 608).

  • <Photo_only_attributes>

    The following attributes are only available for photos.

    • aperture (str): The aperture used to take the photo.

    • exposure (str): The exposure used to take the photo.

    • iso (int): The iso used to take the photo.

    • lens (str): The lens used to take the photo.

    • make (str): The make of the camera used to take the photo.

    • model (str): The model of the camera used to take the photo.

property isOptimizedVersion

Returns True if the media is a Plex optimized version.

class plexapi.media.MediaPart(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Represents a single media part (often a single file) for the media this belongs to.

Variables
  • TAG (str) – ‘Part’

  • accessible (bool) – True if the file is accessible.

  • audioProfile (str) – The audio profile of the file.

  • container (str) – The container type of the file (ex: avi).

  • decision (str) – Unknown.

  • deepAnalysisVersion (int) – The Plex deep analysis version for the file.

  • duration (int) – The duration of the file in milliseconds.

  • exists (bool) – True if the file exists.

  • file (str) – The path to this file on disk (ex: /media/Movies/Cars (2006)/Cars (2006).mkv)

  • has64bitOffsets (bool) – True if the file has 64 bit offsets.

  • hasThumbnail (bool) – True if the file (track) has an embedded thumbnail.

  • id (int) – The unique ID for this media part on the server.

  • indexes (str, None) – sd if the file has generated preview (BIF) thumbnails.

  • key (str) – API URL (ex: /library/parts/46618/1389985872/file.mkv).

  • optimizedForStreaming (bool) – True if the file is optimized for streaming.

  • packetLength (int) – The packet length of the file.

  • requiredBandwidths (str) – The required bandwidths to stream the file.

  • size (int) – The size of the file in bytes (ex: 733884416).

  • streams (List<MediaPartStream>) – List of stream objects.

  • syncItemId (int) – The unique ID for this media part if it is synced.

  • syncState (str) – The sync state for this media part.

  • videoProfile (str) – The video profile of the file.

property hasPreviewThumbnails

Returns True if the media part has generated preview (BIF) thumbnails.

videoStreams()[source]

Returns a list of VideoStream objects in this MediaPart.

audioStreams()[source]

Returns a list of AudioStream objects in this MediaPart.

subtitleStreams()[source]

Returns a list of SubtitleStream objects in this MediaPart.

lyricStreams()[source]

Returns a list of LyricStream objects in this MediaPart.

setDefaultAudioStream(stream)[source]

Set the default AudioStream for this MediaPart.

Parameters

stream (AudioStream) – AudioStream to set as default

setDefaultSubtitleStream(stream)[source]

Set the default SubtitleStream for this MediaPart.

Parameters

stream (SubtitleStream) – SubtitleStream to set as default.

resetDefaultSubtitleStream()[source]

Set default subtitle of this MediaPart to ‘none’.

class plexapi.media.MediaPartStream(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Base class for media streams. These consist of video, audio, subtitles, and lyrics.

Variables
  • bitrate (int) – The bitrate of the stream.

  • codec (str) – The codec of the stream (ex: srt, ac3, mpeg4).

  • default (bool) – True if this is the default stream.

  • displayTitle (str) – The display title of the stream.

  • extendedDisplayTitle (str) – The extended display title of the stream.

  • key (str) – API URL (/library/streams/<id>)

  • id (int) – The unique ID for this stream on the server.

  • index (int) – The index of the stream.

  • language (str) – The language of the stream (ex: English, ไทย).

  • languageCode (str) – The ASCII language code of the stream (ex: eng, tha).

  • languageTag (str) – The two letter language tag of the stream (ex: en, fr).

  • requiredBandwidths (str) – The required bandwidths to stream the file.

  • selected (bool) – True if this stream is selected.

  • streamType (int) – The stream type (1= VideoStream, 2= AudioStream, 3= SubtitleStream).

  • title (str) – The title of the stream.

  • type (int) – Alias for streamType.

class plexapi.media.VideoStream(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaPartStream

Represents a video stream within a MediaPart.

Variables
  • TAG (str) – ‘Stream’

  • STREAMTYPE (int) – 1

  • anamorphic (str) – If the video is anamorphic.

  • bitDepth (int) – The bit depth of the video stream (ex: 8).

  • cabac (int) – The context-adaptive binary arithmetic coding.

  • chromaLocation (str) – The chroma location of the video stream.

  • chromaSubsampling (str) – The chroma subsampling of the video stream (ex: 4:2:0).

  • codecID (str) – The codec ID (ex: XVID).

  • codedHeight (int) – The coded height of the video stream in pixels.

  • codedWidth (int) – The coded width of the video stream in pixels.

  • colorPrimaries (str) – The color primaries of the video stream.

  • colorRange (str) – The color range of the video stream.

  • colorSpace (str) – The color space of the video stream (ex: bt2020).

  • colorTrc (str) – The color trc of the video stream.

  • DOVIBLCompatID (int) – Dolby Vision base layer compatibility ID.

  • DOVIBLPresent (bool) – True if Dolby Vision base layer is present.

  • DOVIELPresent (bool) – True if Dolby Vision enhancement layer is present.

  • DOVILevel (int) – Dolby Vision level.

  • DOVIPresent (bool) – True if Dolby Vision is present.

  • DOVIProfile (int) – Dolby Vision profile.

  • DOVIRPUPresent (bool) – True if Dolby Vision reference processing unit is present.

  • DOVIVersion (float) – The Dolby Vision version.

  • duration (int) – The duration of video stream in milliseconds.

  • frameRate (float) – The frame rate of the video stream (ex: 23.976).

  • frameRateMode (str) – The frame rate mode of the video stream.

  • hasScalingMatrix (bool) – True if video stream has a scaling matrix.

  • height (int) – The height of the video stream in pixels (ex: 1080).

  • level (int) – The codec encoding level of the video stream (ex: 41).

  • profile (str) – The profile of the video stream (ex: asp).

  • pixelAspectRatio (str) – The pixel aspect ratio of the video stream.

  • pixelFormat (str) – The pixel format of the video stream.

  • refFrames (int) – The number of reference frames of the video stream.

  • scanType (str) – The scan type of the video stream (ex: progressive).

  • streamIdentifier (int) – The stream identifier of the video stream.

  • width (int) – The width of the video stream in pixels (ex: 1920).

class plexapi.media.AudioStream(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaPartStream

Represents a audio stream within a MediaPart.

Variables
  • TAG (str) – ‘Stream’

  • STREAMTYPE (int) – 2

  • audioChannelLayout (str) – The audio channel layout of the audio stream (ex: 5.1(side)).

  • bitDepth (int) – The bit depth of the audio stream (ex: 16).

  • bitrateMode (str) – The bitrate mode of the audio stream (ex: cbr).

  • channels (int) – The number of audio channels of the audio stream (ex: 6).

  • duration (int) – The duration of audio stream in milliseconds.

  • profile (str) – The profile of the audio stream.

  • samplingRate (int) – The sampling rate of the audio stream (ex: xxx)

  • streamIdentifier (int) – The stream identifier of the audio stream.

  • <Track_only_attributes>

    The following attributes are only available for tracks.

    • albumGain (float): The gain for the album.

    • albumPeak (float): The peak for the album.

    • albumRange (float): The range for the album.

    • endRamp (str): The end ramp for the track.

    • gain (float): The gain for the track.

    • loudness (float): The loudness for the track.

    • lra (float): The lra for the track.

    • peak (float): The peak for the track.

    • startRamp (str): The start ramp for the track.

class plexapi.media.SubtitleStream(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaPartStream

Represents a audio stream within a MediaPart.

Variables
  • TAG (str) – ‘Stream’

  • STREAMTYPE (int) – 3

  • container (str) – The container of the subtitle stream.

  • forced (bool) – True if this is a forced subtitle.

  • format (str) – The format of the subtitle stream (ex: srt).

  • headerCompression (str) – The header compression of the subtitle stream.

  • transient (str) – Unknown.

class plexapi.media.LyricStream(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaPartStream

Represents a lyric stream within a MediaPart.

Variables
  • TAG (str) – ‘Stream’

  • STREAMTYPE (int) – 4

  • format (str) – The format of the lyric stream (ex: lrc).

  • minLines (int) – The minimum number of lines in the (timed) lyric stream.

  • provider (str) – The provider of the lyric stream (ex: com.plexapp.agents.lyricfind).

  • timed (bool) – True if the lyrics are timed to the track.

class plexapi.media.Session(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Represents a current session.

Variables
  • TAG (str) – ‘Session’

  • id (str) – The unique identifier for the session.

  • bandwidth (int) – The Plex streaming brain reserved bandwidth for the session.

  • location (str) – The location of the session (lan, wan, or cellular)

class plexapi.media.TranscodeSession(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Represents a current transcode session.

Variables
  • TAG (str) – ‘TranscodeSession’

  • audioChannels (int) – The number of audio channels of the transcoded media.

  • audioCodec (str) – The audio codec of the transcoded media.

  • audioDecision (str) – The transcode decision for the audio stream.

  • complete (bool) – True if the transcode is complete.

  • container (str) – The container of the transcoded media.

  • context (str) – The context for the transcode session.

  • duration (int) – The duration of the transcoded media in milliseconds.

  • height (int) – The height of the transcoded media in pixels.

  • key (str) – API URL (ex: /transcode/sessions/<id>).

  • maxOffsetAvailable (float) – Unknown.

  • minOffsetAvailable (float) – Unknown.

  • progress (float) – The progress percentage of the transcode.

  • protocol (str) – The protocol of the transcode.

  • remaining (int) – Unknown.

  • size (int) – The size of the transcoded media in bytes.

  • sourceAudioCodec (str) – The audio codec of the source media.

  • sourceVideoCodec (str) – The video codec of the source media.

  • speed (float) – The speed of the transcode.

  • subtitleDecision (str) – The transcode decision for the subtitle stream

  • throttled (bool) – True if the transcode is throttled.

  • timestamp (int) – The epoch timestamp when the transcode started.

  • transcodeHwDecoding (str) – The hardware transcoding decoder engine.

  • transcodeHwDecodingTitle (str) – The title of the hardware transcoding decoder engine.

  • transcodeHwEncoding (str) – The hardware transcoding encoder engine.

  • transcodeHwEncodingTitle (str) – The title of the hardware transcoding encoder engine.

  • transcodeHwFullPipeline (str) – True if hardware decoding and encoding is being used for the transcode.

  • transcodeHwRequested (str) – True if hardware transcoding was requested for the transcode.

  • videoCodec (str) – The video codec of the transcoded media.

  • videoDecision (str) – The transcode decision for the video stream.

  • width (str) – The width of the transcoded media in pixels.

class plexapi.media.TranscodeJob(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Represents an Optimizing job. TrancodeJobs are the process for optimizing conversions. Active or paused optimization items. Usually one item as a time.

class plexapi.media.Optimized(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Represents a Optimized item. Optimized items are optimized and queued conversions items.

items()[source]

Returns a list of all Video objects in this optimized item.

remove()[source]

Remove an Optimized item

rename(title)[source]

Rename an Optimized item

reprocess(ratingKey)[source]

Reprocess a removed Conversion item that is still a listed Optimize item

class plexapi.media.Conversion(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Represents a Conversion item. Conversions are items queued for optimization or being actively optimized.

remove()[source]

Remove Conversion from queue

move(after)[source]

Move Conversion items position in queue after (int): Place item after specified playQueueItemID. ‘-1’ is the active conversion.

Example:
Move 5th conversion Item to active conversion

conversions[4].move(‘-1’)

Move 4th conversion Item to 3rd in conversion queue

conversions[3].move(conversions[1].playQueueItemID)

class plexapi.media.MediaTag(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Base class for media tags used for filtering and searching your library items or navigating the metadata of media items in your library. Tags are the construct used for things such as Country, Director, Genre, etc.

Variables
  • filter (str) – The library filter for the tag.

  • id (id) – Tag ID (This seems meaningless except to use it as a unique id).

  • key (str) – API URL (/library/section/<librarySectionID>/all?<filter>).

  • role (str) – The name of the character role for Role only.

  • tag (str) – Name of the tag. This will be Animation, SciFi etc for Genres. The name of person for Directors and Roles (ex: Animation, Stephen Graham, etc).

  • thumb (str) – URL to thumbnail image for Role only.

items()[source]

Return the list of items within this tag.

class plexapi.media.Collection(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaTag

Represents a single Collection media tag.

Variables
  • TAG (str) – ‘Collection’

  • FILTER (str) – ‘collection’

collection()[source]

Return the Collection object for this collection tag.

class plexapi.media.Country(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaTag

Represents a single Country media tag.

Variables
  • TAG (str) – ‘Country’

  • FILTER (str) – ‘country’

class plexapi.media.Director(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaTag

Represents a single Director media tag.

Variables
  • TAG (str) – ‘Director’

  • FILTER (str) – ‘director’

class plexapi.media.Format(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaTag

Represents a single Format media tag.

Variables
  • TAG (str) – ‘Format’

  • FILTER (str) – ‘format’

class plexapi.media.Genre(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaTag

Represents a single Genre media tag.

Variables
  • TAG (str) – ‘Genre’

  • FILTER (str) – ‘genre’

class plexapi.media.Label(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaTag

Represents a single Label media tag.

Variables
  • TAG (str) – ‘Label’

  • FILTER (str) – ‘label’

class plexapi.media.Mood(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaTag

Represents a single Mood media tag.

Variables
  • TAG (str) – ‘Mood’

  • FILTER (str) – ‘mood’

class plexapi.media.Producer(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaTag

Represents a single Producer media tag.

Variables
  • TAG (str) – ‘Producer’

  • FILTER (str) – ‘producer’

class plexapi.media.Role(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaTag

Represents a single Role (actor/actress) media tag.

Variables
  • TAG (str) – ‘Role’

  • FILTER (str) – ‘role’

class plexapi.media.Similar(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaTag

Represents a single Similar media tag.

Variables
  • TAG (str) – ‘Similar’

  • FILTER (str) – ‘similar’

class plexapi.media.Style(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaTag

Represents a single Style media tag.

Variables
  • TAG (str) – ‘Style’

  • FILTER (str) – ‘style’

class plexapi.media.Subformat(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaTag

Represents a single Subformat media tag.

Variables
  • TAG (str) – ‘Subformat’

  • FILTER (str) – ‘subformat’

class plexapi.media.Tag(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaTag

Represents a single Tag media tag.

Variables
  • TAG (str) – ‘Tag’

  • FILTER (str) – ‘tag’

class plexapi.media.Writer(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.MediaTag

Represents a single Writer media tag.

Variables
  • TAG (str) – ‘Writer’

  • FILTER (str) – ‘writer’

class plexapi.media.GuidTag(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Base class for guid tags used only for Guids, as they contain only a string identifier

Variables

id (id) – The guid for external metadata sources (e.g. IMDB, TMDB, TVDB, MBID).

class plexapi.media.Guid(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.GuidTag

Represents a single Guid media tag.

Variables

TAG (str) – ‘Guid’

class plexapi.media.Review(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Represents a single Review for a Movie.

Variables
  • TAG (str) – ‘Review’

  • filter (str) – filter for reviews?

  • id (int) – The ID of the review.

  • image (str) – The image uri for the review.

  • link (str) – The url to the online review.

  • source (str) – The source of the review.

  • tag (str) – The name of the reviewer.

  • text (str) – The text of the review.

class plexapi.media.BaseResource(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Base class for all Art, Banner, Poster, and Theme objects.

Variables
  • TAG (str) – ‘Photo’ or ‘Track’

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

  • provider (str) – The source of the art or poster, None for Theme objects.

  • ratingKey (str) – Unique key identifying the resource.

  • selected (bool) – True if the resource is currently selected.

  • thumb (str) – The URL to retrieve the resource thumbnail.

class plexapi.media.Art(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.BaseResource

Represents a single Art object.

class plexapi.media.Banner(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.BaseResource

Represents a single Banner object.

class plexapi.media.Poster(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.BaseResource

Represents a single Poster object.

class plexapi.media.Theme(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.BaseResource

Represents a single Theme object.

class plexapi.media.Chapter(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Represents a single Chapter media tag.

Variables

TAG (str) – ‘Chapter’

class plexapi.media.Marker(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Represents a single Marker media tag.

Variables

TAG (str) – ‘Marker’

class plexapi.media.Field(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Represents a single Field.

Variables

TAG (str) – ‘Field’

class plexapi.media.SearchResult(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Represents a single SearchResult.

Variables

TAG (str) – ‘SearchResult’

class plexapi.media.Agent(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Represents a single Agent.

Variables

TAG (str) – ‘Agent’

class plexapi.media.AgentMediaType(server, data, initpath=None, parent=None)[source]

Bases: plexapi.media.Agent

Represents a single Agent MediaType.

Variables

TAG (str) – ‘MediaType’

class plexapi.media.Availability(server, data, initpath=None, parent=None)[source]

Bases: plexapi.base.PlexObject

Represents a single online streaming service Availability.

Variables
  • TAG (str) – ‘Availability’

  • country (str) – The streaming service country.

  • offerType (str) – Subscription, buy, or rent from the streaming service.

  • platform (str) – The platform slug for the streaming service.

  • platformColorThumb (str) – Thumbnail icon for the streaming service.

  • platformInfo (str) – The streaming service platform info.

  • platformUrl (str) – The URL to the media on the streaming service.

  • price (float) – The price to buy or rent from the streaming service.

  • priceDescription (str) – The display price to buy or rent from the streaming service.

  • quality (str) – The video quality on the streaming service.

  • title (str) – The title of the streaming service.

  • url (str) – The Plex availability URL.