mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 13:41:15 -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
|
@ -3,7 +3,7 @@ from pathlib import Path
|
|||
from urllib.parse import quote_plus
|
||||
|
||||
from plexapi import media, utils
|
||||
from plexapi.base import PlexPartialObject
|
||||
from plexapi.base import PlexPartialObject, cached_data_property
|
||||
from plexapi.exceptions import BadRequest, NotFound, Unsupported
|
||||
from plexapi.library import LibrarySection, ManagedHub
|
||||
from plexapi.mixins import (
|
||||
|
@ -69,7 +69,7 @@ class Collection(
|
|||
TYPE = 'collection'
|
||||
|
||||
def _loadData(self, data):
|
||||
self._data = data
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self.addedAt = utils.toDatetime(data.attrib.get('addedAt'))
|
||||
self.art = data.attrib.get('art')
|
||||
self.artBlurHash = data.attrib.get('artBlurHash')
|
||||
|
@ -81,12 +81,9 @@ class Collection(
|
|||
self.collectionSort = utils.cast(int, data.attrib.get('collectionSort', '0'))
|
||||
self.content = data.attrib.get('content')
|
||||
self.contentRating = data.attrib.get('contentRating')
|
||||
self.fields = self.findItems(data, media.Field)
|
||||
self.guid = data.attrib.get('guid')
|
||||
self.images = self.findItems(data, media.Image)
|
||||
self.index = utils.cast(int, data.attrib.get('index'))
|
||||
self.key = data.attrib.get('key', '').replace('/children', '') # FIX_BUG_50
|
||||
self.labels = self.findItems(data, media.Label)
|
||||
self.lastRatedAt = utils.toDatetime(data.attrib.get('lastRatedAt'))
|
||||
self.librarySectionID = utils.cast(int, data.attrib.get('librarySectionID'))
|
||||
self.librarySectionKey = data.attrib.get('librarySectionKey')
|
||||
|
@ -105,12 +102,24 @@ class Collection(
|
|||
self.title = data.attrib.get('title')
|
||||
self.titleSort = data.attrib.get('titleSort', self.title)
|
||||
self.type = data.attrib.get('type')
|
||||
self.ultraBlurColors = self.findItem(data, media.UltraBlurColors)
|
||||
self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt'))
|
||||
self.userRating = utils.cast(float, data.attrib.get('userRating'))
|
||||
self._items = None # cache for self.items
|
||||
self._section = None # cache for self.section
|
||||
self._filters = None # cache for self.filters
|
||||
|
||||
@cached_data_property
|
||||
def fields(self):
|
||||
return self.findItems(self._data, media.Field)
|
||||
|
||||
@cached_data_property
|
||||
def images(self):
|
||||
return self.findItems(self._data, media.Image)
|
||||
|
||||
@cached_data_property
|
||||
def labels(self):
|
||||
return self.findItems(self._data, media.Label)
|
||||
|
||||
@cached_data_property
|
||||
def ultraBlurColors(self):
|
||||
return self.findItem(self._data, media.UltraBlurColors)
|
||||
|
||||
def __len__(self): # pragma: no cover
|
||||
return len(self.items())
|
||||
|
@ -162,20 +171,26 @@ class Collection(
|
|||
def children(self):
|
||||
return self.items()
|
||||
|
||||
@cached_data_property
|
||||
def _filters(self):
|
||||
""" Cache for filters. """
|
||||
return self._parseFilters(self.content)
|
||||
|
||||
def filters(self):
|
||||
""" Returns the search filter dict for smart collection.
|
||||
The filter dict be passed back into :func:`~plexapi.library.LibrarySection.search`
|
||||
to get the list of items.
|
||||
"""
|
||||
if self.smart and self._filters is None:
|
||||
self._filters = self._parseFilters(self.content)
|
||||
return self._filters
|
||||
|
||||
@cached_data_property
|
||||
def _section(self):
|
||||
""" Cache for section. """
|
||||
return super(Collection, self).section()
|
||||
|
||||
def section(self):
|
||||
""" Returns the :class:`~plexapi.library.LibrarySection` this collection belongs to.
|
||||
"""
|
||||
if self._section is None:
|
||||
self._section = super(Collection, self).section()
|
||||
return self._section
|
||||
|
||||
def item(self, title):
|
||||
|
@ -192,12 +207,14 @@ class Collection(
|
|||
return item
|
||||
raise NotFound(f'Item with title "{title}" not found in the collection')
|
||||
|
||||
@cached_data_property
|
||||
def _items(self):
|
||||
""" Cache for the items. """
|
||||
key = f'{self.key}/children'
|
||||
return self.fetchItems(key)
|
||||
|
||||
def items(self):
|
||||
""" Returns a list of all items in the collection. """
|
||||
if self._items is None:
|
||||
key = f'{self.key}/children'
|
||||
items = self.fetchItems(key)
|
||||
self._items = items
|
||||
return self._items
|
||||
|
||||
def visibility(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue