From db2a210f377418eb5624003bed9b868508b21a46 Mon Sep 17 00:00:00 2001 From: blacktwin Date: Fri, 5 Jun 2020 15:43:05 -0400 Subject: [PATCH] adding fields attribute to library.Collections reordered attributes docstring update --- plexapi/library.py | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/plexapi/library.py b/plexapi/library.py index 397f5c2e..5e87a880 100644 --- a/plexapi/library.py +++ b/plexapi/library.py @@ -1085,6 +1085,29 @@ class Hub(PlexObject): @utils.registerPlexObject class Collections(PlexObject): + """ 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. + fields (list): List of :class:`~plexapi.media.Field`. + key (str): API URL (/library/metadata/). + index (int): Unknown + maxYear (int): Year + minYear (int): YEar + subtype (str): Media type + summary (str): Summary of the collection + thumb (str): URL to thumbnail image. + title (str): Artist, Album or Track title. (Jason Mraz, We Sing, Lucky, etc.) + type (str): Hardcoded 'collection' + + """ TAG = 'Directory' TYPE = 'collection' @@ -1093,20 +1116,21 @@ 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') - self.type = data.attrib.get('type') - self.title = data.attrib.get('title') - 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.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 = data.attrib.get('collectionMode') self.collectionSort = data.attrib.get('collectionSort') + self.fields = self.findItems(data, etag='Field') + self.key = data.attrib.get('key') + self.index = utils.cast(int, data.attrib.get('index')) + 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.thumb = data.attrib.get('thumb') + self.title = data.attrib.get('title') + self.type = data.attrib.get('type') + self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt')) @property def children(self): @@ -1201,4 +1225,4 @@ class Collections(PlexObject): art.select() # def edit(self, **kwargs): - # TODO + # TODO \ No newline at end of file