python-plexapi/plexapi/media.py

932 lines
38 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2020-03-14 14:35:56 +00:00
import xml
2020-05-12 21:15:16 +00:00
from urllib.parse import quote_plus
2020-03-14 14:35:56 +00:00
2020-05-12 21:15:16 +00:00
from plexapi import log, settings, utils
from plexapi.base import PlexObject
from plexapi.exceptions import BadRequest
from plexapi.utils import cast
2014-12-29 03:21:58 +00:00
@utils.registerPlexObject
class Media(PlexObject):
""" Container object for all MediaPart objects. Provides useful data about the
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
video or audio this media belong to such as video framerate, resolution, etc.
Attributes:
TAG (str): 'Media'
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
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.
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
parts (List<:class:`~plexapi.media.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 apeture 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.
"""
TAG = 'Media'
2015-06-08 16:41:47 +00:00
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
2014-12-29 03:21:58 +00:00
self.aspectRatio = cast(float, data.attrib.get('aspectRatio'))
self.audioChannels = cast(int, data.attrib.get('audioChannels'))
self.audioCodec = data.attrib.get('audioCodec')
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.audioProfile = data.attrib.get('audioProfile')
2016-04-10 03:59:47 +00:00
self.bitrate = cast(int, data.attrib.get('bitrate'))
2014-12-29 03:21:58 +00:00
self.container = data.attrib.get('container')
2016-04-10 03:59:47 +00:00
self.duration = cast(int, data.attrib.get('duration'))
self.height = cast(int, data.attrib.get('height'))
self.id = cast(int, data.attrib.get('id'))
self.has64bitOffsets = cast(bool, data.attrib.get('has64bitOffsets'))
2016-04-10 03:59:47 +00:00
self.optimizedForStreaming = cast(bool, data.attrib.get('optimizedForStreaming'))
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.parts = self.findItems(data, MediaPart)
self.proxyType = cast(int, data.attrib.get('proxyType'))
self.target = data.attrib.get('target')
self.title = data.attrib.get('title')
2016-04-10 03:59:47 +00:00
self.videoCodec = data.attrib.get('videoCodec')
self.videoFrameRate = data.attrib.get('videoFrameRate')
self.videoProfile = data.attrib.get('videoProfile')
2016-04-10 03:59:47 +00:00
self.videoResolution = data.attrib.get('videoResolution')
self.width = cast(int, data.attrib.get('width'))
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
if self._isChildOf(etag='Photo'):
self.aperture = data.attrib.get('aperture')
self.exposure = data.attrib.get('exposure')
self.iso = cast(int, data.attrib.get('iso'))
self.lens = data.attrib.get('lens')
self.make = data.attrib.get('make')
self.model = data.attrib.get('model')
@property
def isOptimizedVersion(self):
""" Returns True if the media is a Plex optimized version. """
return self.proxyType == utils.SEARCHTYPES['optimizedVersion']
2014-12-29 03:21:58 +00:00
def delete(self):
part = self._initpath + '/media/%s' % self.id
try:
return self._server.query(part, method=self._server._session.delete)
except BadRequest:
log.error("Failed to delete %s. This could be because you havn't allowed "
"items to be deleted" % part)
raise
2014-12-29 03:21:58 +00:00
@utils.registerPlexObject
class MediaPart(PlexObject):
""" Represents a single media part (often a single file) for the media this belongs to.
Attributes:
TAG (str): 'Part'
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
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 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<:class:`~plexapi.media.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.
"""
TAG = 'Part'
2014-12-29 03:21:58 +00:00
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.accessible = cast(bool, data.attrib.get('accessible'))
self.audioProfile = data.attrib.get('audioProfile')
2016-04-10 03:59:47 +00:00
self.container = data.attrib.get('container')
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.decision = data.attrib.get('decision')
self.deepAnalysisVersion = cast(int, data.attrib.get('deepAnalysisVersion'))
2014-12-29 03:21:58 +00:00
self.duration = cast(int, data.attrib.get('duration'))
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.exists = cast(bool, data.attrib.get('exists'))
2014-12-29 03:21:58 +00:00
self.file = data.attrib.get('file')
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.has64bitOffsets = cast(bool, data.attrib.get('has64bitOffsets'))
self.hasThumbnail = cast(bool, data.attrib.get('hasThumbnail'))
2016-04-10 03:59:47 +00:00
self.id = cast(int, data.attrib.get('id'))
self.indexes = data.attrib.get('indexes')
2016-04-10 03:59:47 +00:00
self.key = data.attrib.get('key')
2018-09-08 15:25:16 +00:00
self.optimizedForStreaming = cast(bool, data.attrib.get('optimizedForStreaming'))
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.packetLength = cast(int, data.attrib.get('packetLength'))
self.requiredBandwidths = data.attrib.get('requiredBandwidths')
self.size = cast(int, data.attrib.get('size'))
self.streams = self._buildStreams(data)
2018-09-08 15:25:16 +00:00
self.syncItemId = cast(int, data.attrib.get('syncItemId'))
self.syncState = data.attrib.get('syncState')
self.videoProfile = data.attrib.get('videoProfile')
2014-12-29 03:21:58 +00:00
def _buildStreams(self, data):
streams = []
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
for cls in (VideoStream, AudioStream, SubtitleStream, LyricStream):
items = self.findItems(data, cls, streamType=cls.STREAMTYPE)
streams.extend(items)
return streams
def videoStreams(self):
""" Returns a list of :class:`~plexapi.media.VideoStream` objects in this MediaPart. """
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
return [stream for stream in self.streams if isinstance(stream, VideoStream)]
def audioStreams(self):
""" Returns a list of :class:`~plexapi.media.AudioStream` objects in this MediaPart. """
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
return [stream for stream in self.streams if isinstance(stream, AudioStream)]
def subtitleStreams(self):
""" Returns a list of :class:`~plexapi.media.SubtitleStream` objects in this MediaPart. """
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
return [stream for stream in self.streams if isinstance(stream, SubtitleStream)]
def lyricStreams(self):
""" Returns a list of :class:`~plexapi.media.SubtitleStream` objects in this MediaPart. """
return [stream for stream in self.streams if isinstance(stream, LyricStream)]
2019-02-05 02:07:22 +00:00
def setDefaultAudioStream(self, stream):
""" Set the default :class:`~plexapi.media.AudioStream` for this MediaPart.
Parameters:
stream (:class:`~plexapi.media.AudioStream`): AudioStream to set as default
"""
2019-02-06 23:22:28 +00:00
if isinstance(stream, AudioStream):
2019-02-04 22:28:30 +00:00
key = "/library/parts/%d?audioStreamID=%d&allParts=1" % (self.id, stream.id)
else:
2019-02-06 23:22:28 +00:00
key = "/library/parts/%d?audioStreamID=%d&allParts=1" % (self.id, stream)
self._server.query(key, method=self._server._session.put)
2019-02-05 02:07:22 +00:00
def setDefaultSubtitleStream(self, stream):
""" Set the default :class:`~plexapi.media.SubtitleStream` for this MediaPart.
2020-03-14 14:35:56 +00:00
Parameters:
2019-02-05 02:07:22 +00:00
stream (:class:`~plexapi.media.SubtitleStream`): SubtitleStream to set as default.
"""
2019-02-06 23:22:28 +00:00
if isinstance(stream, SubtitleStream):
2019-02-04 22:28:30 +00:00
key = "/library/parts/%d?subtitleStreamID=%d&allParts=1" % (self.id, stream.id)
else:
2019-02-06 23:22:28 +00:00
key = "/library/parts/%d?subtitleStreamID=%d&allParts=1" % (self.id, stream)
self._server.query(key, method=self._server._session.put)
2019-02-06 23:22:28 +00:00
def resetDefaultSubtitleStream(self):
2019-02-05 02:07:22 +00:00
""" Set default subtitle of this MediaPart to 'none'. """
key = "/library/parts/%d?subtitleStreamID=0&allParts=1" % (self.id)
self._server.query(key, method=self._server._session.put)
2014-12-29 03:21:58 +00:00
class MediaPartStream(PlexObject):
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
""" Base class for media streams. These consist of video, audio, subtitles, and lyrics.
Attributes:
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
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).
requiredBandwidths (str): The required bandwidths to stream the file.
selected (bool): True if this stream is selected.
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
streamType (int): The stream type (1= :class:`~plexapi.media.VideoStream`,
2= :class:`~plexapi.media.AudioStream`, 3= :class:`~plexapi.media.SubtitleStream`).
title (str): The title of the stream.
type (int): Alias for streamType.
"""
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.bitrate = cast(int, data.attrib.get('bitrate'))
2014-12-29 03:21:58 +00:00
self.codec = data.attrib.get('codec')
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.default = cast(bool, data.attrib.get('default'))
self.displayTitle = data.attrib.get('displayTitle')
self.extendedDisplayTitle = data.attrib.get('extendedDisplayTitle')
self.key = data.attrib.get('key')
self.id = cast(int, data.attrib.get('id'))
2014-12-29 03:21:58 +00:00
self.index = cast(int, data.attrib.get('index', '-1'))
self.language = data.attrib.get('language')
self.languageCode = data.attrib.get('languageCode')
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.requiredBandwidths = data.attrib.get('requiredBandwidths')
self.selected = cast(bool, data.attrib.get('selected', '0'))
self.streamType = cast(int, data.attrib.get('streamType'))
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.title = data.attrib.get('title')
self.type = cast(int, data.attrib.get('streamType'))
2014-12-29 03:21:58 +00:00
@utils.registerPlexObject
class VideoStream(MediaPartStream):
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
""" Represents a video stream within a :class:`~plexapi.media.MediaPart`.
Attributes:
TAG (str): 'Stream'
STREAMTYPE (int): 1
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
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.
hasScallingMatrix (bool): True if video stream has a scaling matrix.
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
height (int): The hight 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).
"""
TAG = 'Stream'
STREAMTYPE = 1
2014-12-29 03:21:58 +00:00
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
super(VideoStream, self)._loadData(data)
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.anamorphic = data.attrib.get('anamorphic')
self.bitDepth = cast(int, data.attrib.get('bitDepth'))
2014-12-29 03:21:58 +00:00
self.cabac = cast(int, data.attrib.get('cabac'))
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.chromaLocation = data.attrib.get('chromaLocation')
self.chromaSubsampling = data.attrib.get('chromaSubsampling')
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.codecID = data.attrib.get('codecID')
self.codedHeight = cast(int, data.attrib.get('codedHeight'))
self.codedWidth = cast(int, data.attrib.get('codedWidth'))
self.colorPrimaries = data.attrib.get('colorPrimaries')
self.colorRange = data.attrib.get('colorRange')
self.colorSpace = data.attrib.get('colorSpace')
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.colorTrc = data.attrib.get('colorTrc')
self.DOVIBLCompatID = cast(int, data.attrib.get('DOVIBLCompatID'))
self.DOVIBLPresent = cast(bool, data.attrib.get('DOVIBLPresent'))
self.DOVIELPresent = cast(bool, data.attrib.get('DOVIELPresent'))
self.DOVILevel = cast(int, data.attrib.get('DOVILevel'))
self.DOVIPresent = cast(bool, data.attrib.get('DOVIPresent'))
self.DOVIProfile = cast(int, data.attrib.get('DOVIProfile'))
self.DOVIRPUPresent = cast(bool, data.attrib.get('DOVIRPUPresent'))
self.DOVIVersion = cast(float, data.attrib.get('DOVIVersion'))
2014-12-29 03:21:58 +00:00
self.duration = cast(int, data.attrib.get('duration'))
self.frameRate = cast(float, data.attrib.get('frameRate'))
self.frameRateMode = data.attrib.get('frameRateMode')
self.hasScallingMatrix = cast(bool, data.attrib.get('hasScallingMatrix'))
2014-12-29 03:21:58 +00:00
self.height = cast(int, data.attrib.get('height'))
self.level = cast(int, data.attrib.get('level'))
self.profile = data.attrib.get('profile')
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.pixelAspectRatio = data.attrib.get('pixelAspectRatio')
self.pixelFormat = data.attrib.get('pixelFormat')
self.refFrames = cast(int, data.attrib.get('refFrames'))
self.scanType = data.attrib.get('scanType')
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.streamIdentifier = cast(int, data.attrib.get('streamIdentifier'))
2014-12-29 03:21:58 +00:00
self.width = cast(int, data.attrib.get('width'))
@utils.registerPlexObject
class AudioStream(MediaPartStream):
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
""" Represents a audio stream within a :class:`~plexapi.media.MediaPart`.
Attributes:
TAG (str): 'Stream'
STREAMTYPE (int): 2
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
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.
"""
TAG = 'Stream'
STREAMTYPE = 2
2014-12-29 03:21:58 +00:00
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
super(AudioStream, self)._loadData(data)
self.audioChannelLayout = data.attrib.get('audioChannelLayout')
self.bitDepth = cast(int, data.attrib.get('bitDepth'))
self.bitrateMode = data.attrib.get('bitrateMode')
2016-04-10 03:59:47 +00:00
self.channels = cast(int, data.attrib.get('channels'))
2014-12-29 03:21:58 +00:00
self.duration = cast(int, data.attrib.get('duration'))
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.profile = data.attrib.get('profile')
self.samplingRate = cast(int, data.attrib.get('samplingRate'))
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.streamIdentifier = cast(int, data.attrib.get('streamIdentifier'))
if self._isChildOf(etag='Track'):
self.albumGain = cast(float, data.attrib.get('albumGain'))
self.albumPeak = cast(float, data.attrib.get('albumPeak'))
self.albumRange = cast(float, data.attrib.get('albumRange'))
self.endRamp = data.attrib.get('endRamp')
self.gain = cast(float, data.attrib.get('gain'))
self.loudness = cast(float, data.attrib.get('loudness'))
self.lra = cast(float, data.attrib.get('lra'))
self.peak = cast(float, data.attrib.get('peak'))
self.startRamp = data.attrib.get('startRamp')
2014-12-29 03:21:58 +00:00
@utils.registerPlexObject
class SubtitleStream(MediaPartStream):
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
""" Represents a audio stream within a :class:`~plexapi.media.MediaPart`.
Attributes:
TAG (str): 'Stream'
STREAMTYPE (int): 3
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
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).
headerCommpression (str): The header compression of the subtitle stream.
transient (str): Unknown.
"""
TAG = 'Stream'
STREAMTYPE = 3
2014-12-29 03:21:58 +00:00
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
super(SubtitleStream, self)._loadData(data)
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.container = data.attrib.get('container')
2019-02-04 19:15:05 +00:00
self.forced = cast(bool, data.attrib.get('forced', '0'))
2014-12-29 03:21:58 +00:00
self.format = data.attrib.get('format')
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
self.headerCompression = data.attrib.get('headerCompression')
self.transient = data.attrib.get('transient')
class LyricStream(MediaPartStream):
""" Represents a lyric stream within a :class:`~plexapi.media.MediaPart`.
Attributes:
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.
"""
TAG = 'Stream'
STREAMTYPE = 4
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
super(LyricStream, self)._loadData(data)
self.format = data.attrib.get('format')
self.minLines = cast(int, data.attrib.get('minLines'))
self.provider = data.attrib.get('provider')
self.timed = cast(bool, data.attrib.get('timed', '0'))
2014-12-29 03:21:58 +00:00
2017-02-26 22:31:09 +00:00
@utils.registerPlexObject
class Session(PlexObject):
2017-02-27 02:12:56 +00:00
""" Represents a current session. """
2017-02-26 22:31:09 +00:00
TAG = 'Session'
def _loadData(self, data):
self.id = data.attrib.get('id')
self.bandwidth = utils.cast(int, data.attrib.get('bandwidth'))
self.location = data.attrib.get('location')
@utils.registerPlexObject
class TranscodeSession(PlexObject):
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
""" Represents a current transcode session. """
TAG = 'TranscodeSession'
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
2016-04-10 03:59:47 +00:00
self.audioChannels = cast(int, data.attrib.get('audioChannels'))
self.audioCodec = data.attrib.get('audioCodec')
self.audioDecision = data.attrib.get('audioDecision')
self.container = data.attrib.get('container')
self.context = data.attrib.get('context')
self.duration = cast(int, data.attrib.get('duration'))
self.height = cast(int, data.attrib.get('height'))
self.key = data.attrib.get('key')
self.progress = cast(float, data.attrib.get('progress'))
self.protocol = data.attrib.get('protocol')
2016-04-10 03:59:47 +00:00
self.remaining = cast(int, data.attrib.get('remaining'))
self.speed = cast(int, data.attrib.get('speed'))
self.throttled = cast(int, data.attrib.get('throttled'))
self.sourceVideoCodec = data.attrib.get('sourceVideoCodec')
self.videoCodec = data.attrib.get('videoCodec')
2016-04-10 03:59:47 +00:00
self.videoDecision = data.attrib.get('videoDecision')
self.width = cast(int, data.attrib.get('width'))
@utils.registerPlexObject
class TranscodeJob(PlexObject):
""" Represents an Optimizing job.
TrancodeJobs are the process for optimizing conversions.
Update to MediaPartStream and inheriting classes (#590) * moving common child (VideoStream, AudioStream, SubtitleStream) attributes to the parent (MediaPartStream) * removal of no longer present attribs in video, audio, subtitle streams * additional attribs to video and mediapart streams * removal of previously unique subtitleStream attribs. attribs are now common or no longer present. * docstring cleanup of video, audio, and subtitle stream; pass 1 * remove codecID checks as this attribute is now longer used. * adding key attrib to parent MediaPartStream. * add transient to SubtitleStream, found in uploaded subtitles * removing dialogNorm related assertion as this attrib has been removed. * update Media class based on PR comments optimizedVersion to be added, need SEARCHTYPES * update MediaPartStream class based on PR comments * update VideoStream class based on PR comments * update AudioStream class based on PR comments * update SubtitleStream class based on PR comments * add LyricStream class based on PR comments * add streamType int and LyricStream to MediaPartStream.parse method * add MediaPart.lyricStreams method * spelling correction * more movement based on PR comments * alpha ordering MediaPart * alpha sort VideoStream * docstring corrections * remove assert stream.dialogNorm from audio test as dialogNorm has been removed. * adding LyricStream to _buildStreams function * adding changes from @johnnywong16 https://github.com/JonnyWong16/python-plexapi/commit/e346f0b4dc92ab04a7b69d3ecb28734883a0e792 * moving unused imports down and together * Address docstring review comments * Change isChildOf for any kwargs * Add Media.isOptimizedVersion property * Add photo and track specific attributes * Remove dead MediaPartStream.parse method * Update media doc strings * Add optimized version doc string * Cast video stream codedHeight and codedWidth to int * Add required bandwidths to streams * Update video tests * Update audio tests * Fix video tests * Fix video tests * Fix video tests Co-authored-by: Jason Lawrence <jjlawren@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
2021-01-24 20:21:56 +00:00
Active or paused optimization items. Usually one item as a time."""
TAG = 'TranscodeJob'
def _loadData(self, data):
self._data = data
self.generatorID = data.attrib.get('generatorID')
self.key = data.attrib.get('key')
self.progress = data.attrib.get('progress')
self.ratingKey = data.attrib.get('ratingKey')
self.size = data.attrib.get('size')
self.targetTagID = data.attrib.get('targetTagID')
self.thumb = data.attrib.get('thumb')
self.title = data.attrib.get('title')
self.type = data.attrib.get('type')
2019-10-09 03:26:42 +00:00
@utils.registerPlexObject
2019-10-10 14:43:52 +00:00
class Optimized(PlexObject):
""" Represents a Optimized item.
Optimized items are optimized and queued conversions items."""
2020-01-27 19:17:49 +00:00
TAG = 'Item'
2019-10-09 03:26:42 +00:00
def _loadData(self, data):
self._data = data
2019-10-09 03:26:42 +00:00
self.id = data.attrib.get('id')
self.composite = data.attrib.get('composite')
self.title = data.attrib.get('title')
self.type = data.attrib.get('type')
self.target = data.attrib.get('target')
2019-10-10 02:28:15 +00:00
self.targetTagID = data.attrib.get('targetTagID')
2019-10-09 03:26:42 +00:00
def remove(self):
""" Remove an Optimized item"""
key = '%s/%s' % (self._initpath, self.id)
self._server.query(key, method=self._server._session.delete)
def rename(self, title):
""" Rename an Optimized item"""
key = '%s/%s?Item[title]=%s' % (self._initpath, self.id, title)
self._server.query(key, method=self._server._session.put)
2019-10-09 03:26:42 +00:00
def reprocess(self, ratingKey):
""" Reprocess a removed Conversion item that is still a listed Optimize item"""
key = '%s/%s/%s/enable' % (self._initpath, self.id, ratingKey)
self._server.query(key, method=self._server._session.put)
2019-10-09 03:26:42 +00:00
2019-10-10 15:11:43 +00:00
@utils.registerPlexObject
class Conversion(PlexObject):
2020-01-29 14:17:20 +00:00
""" Represents a Conversion item.
Conversions are items queued for optimization or being actively optimized."""
2020-01-27 19:16:41 +00:00
TAG = 'Video'
2019-10-10 15:11:43 +00:00
def _loadData(self, data):
2020-03-14 14:35:56 +00:00
self._data = data
self.addedAt = data.attrib.get('addedAt')
self.art = data.attrib.get('art')
self.chapterSource = data.attrib.get('chapterSource')
self.contentRating = data.attrib.get('contentRating')
self.duration = data.attrib.get('duration')
self.generatorID = data.attrib.get('generatorID')
self.generatorType = data.attrib.get('generatorType')
self.guid = data.attrib.get('guid')
self.key = data.attrib.get('key')
self.lastViewedAt = data.attrib.get('lastViewedAt')
self.librarySectionID = data.attrib.get('librarySectionID')
self.librarySectionKey = data.attrib.get('librarySectionKey')
self.librarySectionTitle = data.attrib.get('librarySectionTitle')
self.originallyAvailableAt = data.attrib.get('originallyAvailableAt')
self.playQueueItemID = data.attrib.get('playQueueItemID')
self.playlistID = data.attrib.get('playlistID')
self.primaryExtraKey = data.attrib.get('primaryExtraKey')
self.rating = data.attrib.get('rating')
self.ratingKey = data.attrib.get('ratingKey')
self.studio = data.attrib.get('studio')
self.summary = data.attrib.get('summary')
self.tagline = data.attrib.get('tagline')
self.target = data.attrib.get('target')
self.thumb = data.attrib.get('thumb')
self.title = data.attrib.get('title')
self.type = data.attrib.get('type')
self.updatedAt = data.attrib.get('updatedAt')
self.userID = data.attrib.get('userID')
self.username = data.attrib.get('username')
self.viewOffset = data.attrib.get('viewOffset')
self.year = data.attrib.get('year')
2019-10-10 15:11:43 +00:00
def remove(self):
""" Remove Conversion from queue """
key = '/playlists/%s/items/%s/%s/disable' % (self.playlistID, self.generatorID, self.ratingKey)
self._server.query(key, method=self._server._session.put)
def move(self, after):
""" 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')
2020-04-16 21:18:38 +00:00
Move 4th conversion Item to 3rd in conversion queue
conversions[3].move(conversions[1].playQueueItemID)
"""
key = '%s/items/%s/move?after=%s' % (self._initpath, self.playQueueItemID, after)
self._server.query(key, method=self._server._session.put)
2019-10-10 15:11:43 +00:00
class MediaTag(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.
Attributes:
server (:class:`~plexapi.server.PlexServer`): Server this client is connected to.
id (id): Tag ID (This seems meaningless except to use it as a unique id).
role (str): Unknown
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).
<Hub_Search_Attributes>: Attributes only applicable in search results from
2020-11-23 03:06:30 +00:00
PlexServer :func:`~plexapi.server.PlexServer.search`. They provide details of which
library section the tag was found as well as the url to dig deeper into the results.
* key (str): API URL to dig deeper into this tag (ex: /library/sections/1/all?actor=9081).
* librarySectionID (int): Section ID this tag was generated from.
* librarySectionTitle (str): Library section title this tag was found.
* librarySectionType (str): Media type of the library section this tag was found.
* tagType (int): Tag type ID.
* thumb (str): URL to thumbnail image.
"""
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
2014-12-29 03:21:58 +00:00
self.id = cast(int, data.attrib.get('id'))
self.role = data.attrib.get('role')
2016-04-10 03:59:47 +00:00
self.tag = data.attrib.get('tag')
# additional attributes only from hub search
self.key = data.attrib.get('key')
self.librarySectionID = cast(int, data.attrib.get('librarySectionID'))
self.librarySectionTitle = data.attrib.get('librarySectionTitle')
self.librarySectionType = data.attrib.get('librarySectionType')
self.tagType = cast(int, data.attrib.get('tagType'))
self.thumb = data.attrib.get('thumb')
2014-12-29 03:21:58 +00:00
def items(self, *args, **kwargs):
""" Return the list of items within this tag. This function is only applicable
2020-11-23 03:06:30 +00:00
in search results from PlexServer :func:`~plexapi.server.PlexServer.search`.
"""
if not self.key:
raise BadRequest('Key is not defined for this tag: %s' % self.tag)
return self.fetchItems(self.key)
2014-12-29 03:21:58 +00:00
@utils.registerPlexObject
2017-02-02 03:53:05 +00:00
class Collection(MediaTag):
""" Represents a single Collection media tag.
Attributes:
TAG (str): 'Collection'
FILTER (str): 'collection'
"""
TAG = 'Collection'
2017-02-02 03:53:05 +00:00
FILTER = 'collection'
2017-02-20 05:37:00 +00:00
@utils.registerPlexObject
class Label(MediaTag):
""" Represents a single label media tag.
Attributes:
TAG (str): 'label'
FILTER (str): 'label'
"""
TAG = 'Label'
FILTER = 'label'
2019-11-11 14:32:55 +00:00
@utils.registerPlexObject
class Tag(MediaTag):
""" Represents a single tag media tag.
Attributes:
TAG (str): 'tag'
FILTER (str): 'tag'
"""
TAG = 'Tag'
FILTER = 'tag'
def _loadData(self, data):
self._data = data
self.id = cast(int, data.attrib.get('id', 0))
self.filter = data.attrib.get('filter')
self.tag = data.attrib.get('tag')
self.title = self.tag
@utils.registerPlexObject
2017-02-02 03:53:05 +00:00
class Country(MediaTag):
""" Represents a single Country media tag.
Attributes:
TAG (str): 'Country'
FILTER (str): 'country'
"""
TAG = 'Country'
2017-02-02 03:53:05 +00:00
FILTER = 'country'
2017-02-20 05:37:00 +00:00
@utils.registerPlexObject
2017-02-02 03:53:05 +00:00
class Director(MediaTag):
""" Represents a single Director media tag.
Attributes:
TAG (str): 'Director'
FILTER (str): 'director'
"""
TAG = 'Director'
2017-02-02 03:53:05 +00:00
FILTER = 'director'
2017-02-20 05:37:00 +00:00
@utils.registerPlexObject
2017-02-02 03:53:05 +00:00
class Genre(MediaTag):
""" Represents a single Genre media tag.
Attributes:
TAG (str): 'Genre'
FILTER (str): 'genre'
"""
TAG = 'Genre'
2017-02-02 03:53:05 +00:00
FILTER = 'genre'
2017-02-20 05:37:00 +00:00
@utils.registerPlexObject
2017-02-02 03:53:05 +00:00
class Mood(MediaTag):
""" Represents a single Mood media tag.
Attributes:
TAG (str): 'Mood'
FILTER (str): 'mood'
"""
TAG = 'Mood'
2017-02-02 03:53:05 +00:00
FILTER = 'mood'
2017-02-20 05:37:00 +00:00
2020-12-23 21:08:46 +00:00
@utils.registerPlexObject
class Style(MediaTag):
""" Represents a single Style media tag.
Attributes:
TAG (str): 'Style'
FILTER (str): 'style'
"""
TAG = 'Style'
FILTER = 'style'
2019-10-09 14:44:51 +00:00
@utils.registerPlexObject
class Poster(PlexObject):
""" Represents a Poster.
Attributes:
2019-11-06 14:28:19 +00:00
TAG (str): 'Photo'
2019-10-09 14:44:51 +00:00
"""
2019-11-06 14:28:19 +00:00
TAG = 'Photo'
2019-10-09 14:44:51 +00:00
def _loadData(self, data):
self._data = data
self.key = data.attrib.get('key')
self.ratingKey = data.attrib.get('ratingKey')
self.selected = data.attrib.get('selected')
self.thumb = data.attrib.get('thumb')
def select(self):
key = self._initpath[:-1]
2020-05-12 21:15:16 +00:00
data = '%s?url=%s' % (key, quote_plus(self.ratingKey))
2020-03-14 14:35:56 +00:00
try:
self._server.query(data, method=self._server._session.put)
except xml.etree.ElementTree.ParseError:
pass
2019-10-09 14:44:51 +00:00
@utils.registerPlexObject
2017-02-02 03:53:05 +00:00
class Producer(MediaTag):
""" Represents a single Producer media tag.
Attributes:
TAG (str): 'Producer'
FILTER (str): 'producer'
"""
TAG = 'Producer'
2017-02-02 03:53:05 +00:00
FILTER = 'producer'
2017-02-20 05:37:00 +00:00
@utils.registerPlexObject
2017-02-02 03:53:05 +00:00
class Role(MediaTag):
""" Represents a single Role (actor/actress) media tag.
Attributes:
TAG (str): 'Role'
FILTER (str): 'role'
"""
TAG = 'Role'
2017-02-02 03:53:05 +00:00
FILTER = 'role'
2017-02-20 05:37:00 +00:00
@utils.registerPlexObject
2017-02-02 03:53:05 +00:00
class Similar(MediaTag):
""" Represents a single Similar media tag.
Attributes:
TAG (str): 'Similar'
FILTER (str): 'similar'
"""
TAG = 'Similar'
2017-02-02 03:53:05 +00:00
FILTER = 'similar'
2017-02-20 05:37:00 +00:00
@utils.registerPlexObject
2017-02-02 03:53:05 +00:00
class Writer(MediaTag):
""" Represents a single Writer media tag.
Attributes:
TAG (str): 'Writer'
FILTER (str): 'writer'
"""
TAG = 'Writer'
2017-02-02 03:53:05 +00:00
FILTER = 'writer'
2016-10-02 20:05:37 +00:00
2017-02-20 05:37:00 +00:00
2018-03-02 12:15:15 +00:00
@utils.registerPlexObject
class Chapter(PlexObject):
""" Represents a single Writer media tag.
Attributes:
TAG (str): 'Chapter'
"""
TAG = 'Chapter'
def _loadData(self, data):
self._data = data
self.id = cast(int, data.attrib.get('id', 0))
self.filter = data.attrib.get('filter') # I couldn't filter on it anyways
self.tag = data.attrib.get('tag')
self.title = self.tag
self.index = cast(int, data.attrib.get('index'))
self.start = cast(int, data.attrib.get('startTimeOffset'))
self.end = cast(int, data.attrib.get('endTimeOffset'))
2020-05-23 06:09:22 +00:00
@utils.registerPlexObject
class Marker(PlexObject):
""" Represents a single Marker media tag.
Attributes:
TAG (str): 'Marker'
"""
TAG = 'Marker'
def __repr__(self):
name = self._clean(self.firstAttr('type'))
2020-06-14 18:21:46 +00:00
start = utils.millisecondToHumanstr(self._clean(self.firstAttr('start')))
end = utils.millisecondToHumanstr(self._clean(self.firstAttr('end')))
return '<%s:%s %s - %s>' % (self.__class__.__name__, name, start, end)
2020-05-23 06:09:22 +00:00
def _loadData(self, data):
self._data = data
self.type = data.attrib.get('type')
self.start = cast(int, data.attrib.get('startTimeOffset'))
self.end = cast(int, data.attrib.get('endTimeOffset'))
2020-10-21 12:58:56 +00:00
@utils.registerPlexObject
class Field(PlexObject):
""" Represents a single Field.
Attributes:
TAG (str): 'Field'
"""
TAG = 'Field'
2016-10-02 20:05:37 +00:00
def _loadData(self, data):
self._data = data
2016-10-02 20:05:37 +00:00
self.name = data.attrib.get('name')
self.locked = cast(bool, data.attrib.get('locked'))
2020-03-04 21:21:13 +00:00
@utils.registerPlexObject
class SearchResult(PlexObject):
""" Represents a single SearchResult.
Attributes:
TAG (str): 'SearchResult'
"""
TAG = 'SearchResult'
def __repr__(self):
name = self._clean(self.firstAttr('name'))
score = self._clean(self.firstAttr('score'))
return '<%s>' % ':'.join([p for p in [self.__class__.__name__, name, score] if p])
2020-03-04 21:21:13 +00:00
def _loadData(self, data):
self._data = data
self.guid = data.attrib.get('guid')
self.lifespanEnded = data.attrib.get('lifespanEnded')
self.name = data.attrib.get('name')
self.score = cast(int, data.attrib.get('score'))
2020-03-04 21:21:13 +00:00
self.year = data.attrib.get('year')
2020-03-10 20:06:43 +00:00
@utils.registerPlexObject
class Agent(PlexObject):
""" Represents a single Agent.
Attributes:
TAG (str): 'Agent'
"""
TAG = 'Agent'
def __repr__(self):
uid = self._clean(self.firstAttr('shortIdentifier'))
return '<%s>' % ':'.join([p for p in [self.__class__.__name__, uid] if p])
2020-03-10 20:06:43 +00:00
def _loadData(self, data):
self._data = data
self.hasAttribution = data.attrib.get('hasAttribution')
self.hasPrefs = data.attrib.get('hasPrefs')
self.identifier = data.attrib.get('identifier')
2020-03-10 20:17:24 +00:00
self.primary = data.attrib.get('primary')
self.shortIdentifier = self.identifier.rsplit('.', 1)[1]
if 'mediaType' in self._initpath:
self.name = data.attrib.get('name')
self.languageCode = []
for code in data:
self.languageCode += [code.attrib.get('code')]
else:
self.mediaTypes = [AgentMediaType(server=self._server, data=d) for d in data]
def _settings(self):
key = '/:/plugins/%s/prefs' % self.identifier
data = self._server.query(key)
return self.findItems(data, cls=settings.Setting)
class AgentMediaType(Agent):
def __repr__(self):
uid = self._clean(self.firstAttr('name'))
return '<%s>' % ':'.join([p for p in [self.__class__.__name__, uid] if p])
def _loadData(self, data):
2020-03-16 17:53:10 +00:00
self.mediaType = cast(int, data.attrib.get('mediaType'))
self.name = data.attrib.get('name')
2020-03-16 19:10:37 +00:00
self.languageCode = []
for code in data:
self.languageCode += [code.attrib.get('code')]