mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-08 06:00:51 -07:00
Update plexapi==4.17.0
This commit is contained in:
parent
3cb71f94a3
commit
f6bffe1850
32 changed files with 1224 additions and 966 deletions
|
@ -1,10 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import xml
|
||||
from pathlib import Path
|
||||
from urllib.parse import quote_plus
|
||||
from xml.etree import ElementTree
|
||||
|
||||
from plexapi import log, settings, utils
|
||||
from plexapi.base import PlexObject
|
||||
from plexapi.base import PlexObject, cached_data_property
|
||||
from plexapi.exceptions import BadRequest
|
||||
from plexapi.utils import deprecated
|
||||
|
||||
|
@ -51,7 +51,6 @@ class Media(PlexObject):
|
|||
|
||||
def _loadData(self, data):
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self._data = data
|
||||
self.aspectRatio = utils.cast(float, data.attrib.get('aspectRatio'))
|
||||
self.audioChannels = utils.cast(int, data.attrib.get('audioChannels'))
|
||||
self.audioCodec = data.attrib.get('audioCodec')
|
||||
|
@ -64,7 +63,6 @@ class Media(PlexObject):
|
|||
self.has64bitOffsets = utils.cast(bool, data.attrib.get('has64bitOffsets'))
|
||||
self.hasVoiceActivity = utils.cast(bool, data.attrib.get('hasVoiceActivity', '0'))
|
||||
self.optimizedForStreaming = utils.cast(bool, data.attrib.get('optimizedForStreaming'))
|
||||
self.parts = self.findItems(data, MediaPart)
|
||||
self.proxyType = utils.cast(int, data.attrib.get('proxyType'))
|
||||
self.selected = utils.cast(bool, data.attrib.get('selected'))
|
||||
self.target = data.attrib.get('target')
|
||||
|
@ -87,6 +85,10 @@ class Media(PlexObject):
|
|||
parent = self._parent()
|
||||
self._parentKey = parent.key
|
||||
|
||||
@cached_data_property
|
||||
def parts(self):
|
||||
return self.findItems(self._data, MediaPart)
|
||||
|
||||
@property
|
||||
def isOptimizedVersion(self):
|
||||
""" Returns True if the media is a Plex optimized version. """
|
||||
|
@ -138,7 +140,6 @@ class MediaPart(PlexObject):
|
|||
|
||||
def _loadData(self, data):
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self._data = data
|
||||
self.accessible = utils.cast(bool, data.attrib.get('accessible'))
|
||||
self.audioProfile = data.attrib.get('audioProfile')
|
||||
self.container = data.attrib.get('container')
|
||||
|
@ -268,7 +269,6 @@ class MediaPartStream(PlexObject):
|
|||
|
||||
def _loadData(self, data):
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self._data = data
|
||||
self.bitrate = utils.cast(int, data.attrib.get('bitrate'))
|
||||
self.codec = data.attrib.get('codec')
|
||||
self.decision = data.attrib.get('decision')
|
||||
|
@ -386,6 +386,7 @@ class AudioStream(MediaPartStream):
|
|||
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.
|
||||
visualImpaired (bool): True if this is a visually impaired (AD) audio stream.
|
||||
|
||||
Track_only_attributes: The following attributes are only available for tracks.
|
||||
|
||||
|
@ -413,6 +414,7 @@ class AudioStream(MediaPartStream):
|
|||
self.profile = data.attrib.get('profile')
|
||||
self.samplingRate = utils.cast(int, data.attrib.get('samplingRate'))
|
||||
self.streamIdentifier = utils.cast(int, data.attrib.get('streamIdentifier'))
|
||||
self.visualImpaired = utils.cast(bool, data.attrib.get('visualImpaired', '0'))
|
||||
|
||||
# Track only attributes
|
||||
self.albumGain = utils.cast(float, data.attrib.get('albumGain'))
|
||||
|
@ -523,6 +525,7 @@ class Session(PlexObject):
|
|||
TAG = 'Session'
|
||||
|
||||
def _loadData(self, data):
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self.id = data.attrib.get('id')
|
||||
self.bandwidth = utils.cast(int, data.attrib.get('bandwidth'))
|
||||
self.location = data.attrib.get('location')
|
||||
|
@ -569,7 +572,6 @@ class TranscodeSession(PlexObject):
|
|||
|
||||
def _loadData(self, data):
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self._data = data
|
||||
self.audioChannels = utils.cast(int, data.attrib.get('audioChannels'))
|
||||
self.audioCodec = data.attrib.get('audioCodec')
|
||||
self.audioDecision = data.attrib.get('audioDecision')
|
||||
|
@ -610,7 +612,7 @@ class TranscodeJob(PlexObject):
|
|||
TAG = 'TranscodeJob'
|
||||
|
||||
def _loadData(self, data):
|
||||
self._data = data
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self.generatorID = data.attrib.get('generatorID')
|
||||
self.key = data.attrib.get('key')
|
||||
self.progress = data.attrib.get('progress')
|
||||
|
@ -629,7 +631,7 @@ class Optimized(PlexObject):
|
|||
TAG = 'Item'
|
||||
|
||||
def _loadData(self, data):
|
||||
self._data = data
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self.id = data.attrib.get('id')
|
||||
self.composite = data.attrib.get('composite')
|
||||
self.title = data.attrib.get('title')
|
||||
|
@ -667,7 +669,7 @@ class Conversion(PlexObject):
|
|||
TAG = 'Video'
|
||||
|
||||
def _loadData(self, data):
|
||||
self._data = data
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self.addedAt = data.attrib.get('addedAt')
|
||||
self.art = data.attrib.get('art')
|
||||
self.chapterSource = data.attrib.get('chapterSource')
|
||||
|
@ -743,7 +745,6 @@ class MediaTag(PlexObject):
|
|||
|
||||
def _loadData(self, data):
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self._data = data
|
||||
self.filter = data.attrib.get('filter')
|
||||
self.id = utils.cast(int, data.attrib.get('id'))
|
||||
self.key = data.attrib.get('key')
|
||||
|
@ -954,7 +955,6 @@ class Guid(PlexObject):
|
|||
|
||||
def _loadData(self, data):
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self._data = data
|
||||
self.id = data.attrib.get('id')
|
||||
|
||||
|
||||
|
@ -972,7 +972,6 @@ class Image(PlexObject):
|
|||
|
||||
def _loadData(self, data):
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self._data = data
|
||||
self.alt = data.attrib.get('alt')
|
||||
self.type = data.attrib.get('type')
|
||||
self.url = data.attrib.get('url')
|
||||
|
@ -994,7 +993,6 @@ class Rating(PlexObject):
|
|||
|
||||
def _loadData(self, data):
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self._data = data
|
||||
self.image = data.attrib.get('image')
|
||||
self.type = data.attrib.get('type')
|
||||
self.value = utils.cast(float, data.attrib.get('value'))
|
||||
|
@ -1017,7 +1015,7 @@ class Review(PlexObject):
|
|||
TAG = 'Review'
|
||||
|
||||
def _loadData(self, data):
|
||||
self._data = data
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self.filter = data.attrib.get('filter')
|
||||
self.id = utils.cast(int, data.attrib.get('id', 0))
|
||||
self.image = data.attrib.get('image')
|
||||
|
@ -1042,7 +1040,6 @@ class UltraBlurColors(PlexObject):
|
|||
|
||||
def _loadData(self, data):
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self._data = data
|
||||
self.bottomLeft = data.attrib.get('bottomLeft')
|
||||
self.bottomRight = data.attrib.get('bottomRight')
|
||||
self.topLeft = data.attrib.get('topLeft')
|
||||
|
@ -1063,7 +1060,7 @@ class BaseResource(PlexObject):
|
|||
"""
|
||||
|
||||
def _loadData(self, data):
|
||||
self._data = data
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self.key = data.attrib.get('key')
|
||||
self.provider = data.attrib.get('provider')
|
||||
self.ratingKey = data.attrib.get('ratingKey')
|
||||
|
@ -1075,7 +1072,7 @@ class BaseResource(PlexObject):
|
|||
data = f'{key}?url={quote_plus(self.ratingKey)}'
|
||||
try:
|
||||
self._server.query(data, method=self._server._session.put)
|
||||
except xml.etree.ElementTree.ParseError:
|
||||
except ElementTree.ParseError:
|
||||
pass
|
||||
|
||||
@property
|
||||
|
@ -1138,7 +1135,7 @@ class Chapter(PlexObject):
|
|||
return f"<{':'.join([self.__class__.__name__, name, offsets])}>"
|
||||
|
||||
def _loadData(self, data):
|
||||
self._data = data
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self.end = utils.cast(int, data.attrib.get('endTimeOffset'))
|
||||
self.filter = data.attrib.get('filter')
|
||||
self.id = utils.cast(int, data.attrib.get('id', 0))
|
||||
|
@ -1172,7 +1169,7 @@ class Marker(PlexObject):
|
|||
return f"<{':'.join([self.__class__.__name__, name, offsets])}>"
|
||||
|
||||
def _loadData(self, data):
|
||||
self._data = data
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self.end = utils.cast(int, data.attrib.get('endTimeOffset'))
|
||||
self.final = utils.cast(bool, data.attrib.get('final'))
|
||||
self.id = utils.cast(int, data.attrib.get('id'))
|
||||
|
@ -1206,7 +1203,7 @@ class Field(PlexObject):
|
|||
TAG = 'Field'
|
||||
|
||||
def _loadData(self, data):
|
||||
self._data = data
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self.locked = utils.cast(bool, data.attrib.get('locked'))
|
||||
self.name = data.attrib.get('name')
|
||||
|
||||
|
@ -1226,7 +1223,7 @@ class SearchResult(PlexObject):
|
|||
return f"<{':'.join([p for p in [self.__class__.__name__, name, score] if p])}>"
|
||||
|
||||
def _loadData(self, data):
|
||||
self._data = data
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self.guid = data.attrib.get('guid')
|
||||
self.lifespanEnded = data.attrib.get('lifespanEnded')
|
||||
self.name = data.attrib.get('name')
|
||||
|
@ -1248,7 +1245,7 @@ class Agent(PlexObject):
|
|||
return f"<{':'.join([p for p in [self.__class__.__name__, uid] if p])}>"
|
||||
|
||||
def _loadData(self, data):
|
||||
self._data = data
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self.hasAttribution = data.attrib.get('hasAttribution')
|
||||
self.hasPrefs = data.attrib.get('hasPrefs')
|
||||
self.identifier = data.attrib.get('identifier')
|
||||
|
@ -1256,12 +1253,17 @@ class Agent(PlexObject):
|
|||
self.primary = data.attrib.get('primary')
|
||||
self.shortIdentifier = self.identifier.rsplit('.', 1)[1]
|
||||
|
||||
@cached_data_property
|
||||
def languageCodes(self):
|
||||
if 'mediaType' in self._initpath:
|
||||
self.languageCodes = self.listAttrs(data, 'code', etag='Language')
|
||||
self.mediaTypes = []
|
||||
else:
|
||||
self.languageCodes = []
|
||||
self.mediaTypes = self.findItems(data, cls=AgentMediaType)
|
||||
return self.listAttrs(self._data, 'code', etag='Language')
|
||||
return []
|
||||
|
||||
@cached_data_property
|
||||
def mediaTypes(self):
|
||||
if 'mediaType' not in self._initpath:
|
||||
return self.findItems(self._data, cls=AgentMediaType)
|
||||
return []
|
||||
|
||||
@property
|
||||
@deprecated('use "languageCodes" instead')
|
||||
|
@ -1291,10 +1293,14 @@ class AgentMediaType(Agent):
|
|||
return f"<{':'.join([p for p in [self.__class__.__name__, uid] if p])}>"
|
||||
|
||||
def _loadData(self, data):
|
||||
self.languageCodes = self.listAttrs(data, 'code', etag='Language')
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self.mediaType = utils.cast(int, data.attrib.get('mediaType'))
|
||||
self.name = data.attrib.get('name')
|
||||
|
||||
@cached_data_property
|
||||
def languageCodes(self):
|
||||
return self.listAttrs(self._data, 'code', etag='Language')
|
||||
|
||||
@property
|
||||
@deprecated('use "languageCodes" instead')
|
||||
def languageCode(self):
|
||||
|
@ -1325,7 +1331,7 @@ class Availability(PlexObject):
|
|||
return f'<{self.__class__.__name__}:{self.platform}:{self.offerType}>'
|
||||
|
||||
def _loadData(self, data):
|
||||
self._data = data
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self.country = data.attrib.get('country')
|
||||
self.offerType = data.attrib.get('offerType')
|
||||
self.platform = data.attrib.get('platform')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue