mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 13:11:15 -07:00
Patch plexapi.library.Collections to PlexPartialObject
This commit is contained in:
parent
ecbe79b5b9
commit
ec9e2fe0f0
5 changed files with 48 additions and 25 deletions
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from plexapi import X_PLEX_CONTAINER_SIZE, log, utils, media
|
||||
from plexapi.base import PlexObject
|
||||
from plexapi.base import PlexObject, PlexPartialObject
|
||||
from plexapi.compat import quote, quote_plus, unquote, urlencode
|
||||
from plexapi.exceptions import BadRequest, NotFound
|
||||
from plexapi.media import MediaTag
|
||||
|
@ -1106,7 +1106,35 @@ class Hub(PlexObject):
|
|||
|
||||
|
||||
@utils.registerPlexObject
|
||||
class Collections(PlexObject):
|
||||
class Collections(PlexPartialObject):
|
||||
""" Represents a single Collection.
|
||||
Attributes:
|
||||
TAG (str): 'Directory'
|
||||
TYPE (str): 'collection'
|
||||
ratingKey (int): Unique key identifying this item.
|
||||
addedAt (datetime): Datetime this item was added to the library.
|
||||
childCount (int): Count of child object(s)
|
||||
collectionMode (str): How the items in the collection are displayed.
|
||||
collectionSort (str): How to sort the items in the collection.
|
||||
contentRating (str) Content rating (PG-13; NR; TV-G).
|
||||
fields (list): List of :class:`~plexapi.media.Field`.
|
||||
guid (str): Plex GUID (collection://XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX).
|
||||
index (int): Unknown
|
||||
key (str): API URL (/library/metadata/<ratingkey>).
|
||||
labels (List<:class:`~plexapi.media.Label`>): List of field objects.
|
||||
librarySectionID (int): :class:`~plexapi.library.LibrarySection` ID.
|
||||
librarySectionKey (str): API URL (/library/sections/<sectionkey>).
|
||||
librarySectionTitle (str): Section Title
|
||||
maxYear (int): Year
|
||||
minYear (int): Year
|
||||
subtype (str): Media type
|
||||
summary (str): Summary of the collection
|
||||
thumb (str): URL to thumbnail image.
|
||||
title (str): Collection Title
|
||||
titleSort (str): Title to use when sorting (defaults to title).
|
||||
type (str): Hardcoded 'collection'
|
||||
updatedAt (datatime): Datetime this item was updated.
|
||||
"""
|
||||
|
||||
TAG = 'Directory'
|
||||
TYPE = 'collection'
|
||||
|
@ -1114,30 +1142,30 @@ class Collections(PlexObject):
|
|||
|
||||
def _loadData(self, data):
|
||||
self.ratingKey = utils.cast(int, data.attrib.get('ratingKey'))
|
||||
self._details_key = "/library/metadata/%s%s" % (self.ratingKey, self._include)
|
||||
self.key = data.attrib.get('key').replace('/children', '') # FIX_BUG_50
|
||||
self._details_key = self.key + self._include
|
||||
self.addedAt = utils.toDatetime(data.attrib.get('addedAt'))
|
||||
self.art = data.attrib.get('art')
|
||||
self.childCount = utils.cast(int, data.attrib.get('childCount'))
|
||||
self.collectionMode = utils.cast(int, data.attrib.get('collectionMode'))
|
||||
self.collectionSort = utils.cast(int, data.attrib.get('collectionSort'))
|
||||
self.contentRating = data.attrib.get('contentRating')
|
||||
self.fields = self.findItems(data, media.Field)
|
||||
self.guid = data.attrib.get('guid')
|
||||
self.key = data.attrib.get('key')
|
||||
self.index = utils.cast(int, data.attrib.get('index'))
|
||||
self.labels = self.findItems(data, media.Label)
|
||||
self.librarySectionID = data.attrib.get('librarySectionID')
|
||||
self.librarySectionKey = data.attrib.get('librarySectionKey')
|
||||
self.librarySectionTitle = data.attrib.get('librarySectionTitle')
|
||||
self.type = data.attrib.get('type')
|
||||
self.title = data.attrib.get('title')
|
||||
self.titleSort = data.attrib.get('titleSort')
|
||||
self.maxYear = utils.cast(int, data.attrib.get('maxYear'))
|
||||
self.minYear = utils.cast(int, data.attrib.get('minYear'))
|
||||
self.subtype = data.attrib.get('subtype')
|
||||
self.summary = data.attrib.get('summary')
|
||||
self.index = utils.cast(int, data.attrib.get('index'))
|
||||
self.thumb = data.attrib.get('thumb')
|
||||
self.addedAt = utils.toDatetime(data.attrib.get('addedAt'))
|
||||
self.title = data.attrib.get('title')
|
||||
self.titleSort = data.attrib.get('titleSort')
|
||||
self.type = data.attrib.get('type')
|
||||
self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt'))
|
||||
self.childCount = utils.cast(int, data.attrib.get('childCount'))
|
||||
self.minYear = utils.cast(int, data.attrib.get('minYear'))
|
||||
self.maxYear = utils.cast(int, data.attrib.get('maxYear'))
|
||||
self.collectionMode = utils.cast(int, data.attrib.get('collectionMode'))
|
||||
self.collectionSort = utils.cast(int, data.attrib.get('collectionSort'))
|
||||
self.labels = self.findItems(data, media.Label)
|
||||
self.fields = self.findItems(data, media.Field)
|
||||
|
||||
@property
|
||||
def children(self):
|
||||
|
@ -1162,14 +1190,12 @@ class Collections(PlexObject):
|
|||
|
||||
def modeUpdate(self, mode=None):
|
||||
""" Update Collection Mode
|
||||
|
||||
Parameters:
|
||||
mode: default (Library default)
|
||||
hide (Hide Collection)
|
||||
hideItems (Hide Items in this Collection)
|
||||
showItems (Show this Collection and its Items)
|
||||
Example:
|
||||
|
||||
collection = 'plexapi.library.Collections'
|
||||
collection.updateMode(mode="hide")
|
||||
"""
|
||||
|
@ -1185,13 +1211,10 @@ class Collections(PlexObject):
|
|||
|
||||
def sortUpdate(self, sort=None):
|
||||
""" Update Collection Sorting
|
||||
|
||||
Parameters:
|
||||
sort: realease (Order Collection by realease dates)
|
||||
alpha (Order Collection Alphabetically)
|
||||
|
||||
Example:
|
||||
|
||||
colleciton = 'plexapi.library.Collections'
|
||||
collection.updateSort(mode="alpha")
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue