Update plexapi.video.Clip and plexapi.photo.Photoalbum

This commit is contained in:
JonnyWong16 2020-10-04 01:18:05 -07:00
parent 6e41b7ef3d
commit 36f877c7ff
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
2 changed files with 13 additions and 4 deletions

View file

@ -38,7 +38,7 @@ class Photoalbum(PlexPartialObject):
self.composite = data.attrib.get('composite')
self.guid = data.attrib.get('guid')
self.index = utils.cast(int, data.attrib.get('index'))
self.key = data.attrib.get('key')
self.key = data.attrib.get('key', '').replace('/children', '')
self.librarySectionID = data.attrib.get('librarySectionID')
self.librarySectionKey = data.attrib.get('librarySectionKey')
self.librarySectionTitle = data.attrib.get('librarySectionTitle')
@ -75,6 +75,11 @@ class Photoalbum(PlexPartialObject):
return photo
raise NotFound('Unable to find photo: %s' % title)
def clips(self, **kwargs):
""" Returns a list of :class:`~plexapi.video.Clip` objects in this album. """
key = '/library/metadata/%s/children' % self.ratingKey
return self.fetchItems(key, etag='Video', **kwargs)
@utils.registerPlexObject
class Photo(PlexPartialObject):

View file

@ -750,12 +750,15 @@ class Clip(Playable, Video):
METADATA_TYPE = 'clip'
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
Video._loadData(self, data)
Playable._loadData(self, data)
self._data = data
self.addedAt = data.attrib.get('addedAt')
self.duration = data.attrib.get('duration')
self.duration = utils.cast(int, data.attrib.get('duration'))
self.guid = data.attrib.get('guid')
self.key = data.attrib.get('key')
self.originallyAvailableAt = data.attrib.get('originallyAvailableAt')
self.originallyAvailableAt = utils.toDatetime(data.attrib.get('originallyAvailableAt'), '%Y-%m-%d')
self.ratingKey = data.attrib.get('ratingKey')
self.skipDetails = utils.cast(int, data.attrib.get('skipDetails'))
self.subtype = data.attrib.get('subtype')
@ -763,4 +766,5 @@ class Clip(Playable, Video):
self.thumbAspectRatio = data.attrib.get('thumbAspectRatio')
self.title = data.attrib.get('title')
self.type = data.attrib.get('type')
self.year = data.attrib.get('year')
self.year = utils.cast(int, data.attrib.get('year'))
self.media = self.findItems(data, media.Media)