mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 14:14:19 +00:00
Add support to recursivly navigate photoalbums
This commit is contained in:
parent
cbb999a0f5
commit
d41bf0fb89
1 changed files with 20 additions and 1 deletions
|
@ -46,10 +46,22 @@ class Photoalbum(PlexPartialObject):
|
|||
self.type = data.attrib.get('type')
|
||||
self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt'))
|
||||
|
||||
def albums(self, **kwargs):
|
||||
""" Returns a list of :class:`~plexapi.photo.Photoalbum` objects in this album. """
|
||||
key = '/library/metadata/%s/children' % self.ratingKey
|
||||
return self.fetchItems(key, etag='Directory', **kwargs)
|
||||
|
||||
def album(self, title):
|
||||
""" Returns the :class:`~plexapi.photo.Photoalbum` that matches the specified title. """
|
||||
for album in self.albums():
|
||||
if album.attrib.get('title').lower() == title.lower():
|
||||
return album
|
||||
raise NotFound('Unable to find album: %s' % title)
|
||||
|
||||
def photos(self, **kwargs):
|
||||
""" Returns a list of :class:`~plexapi.photo.Photo` objects in this album. """
|
||||
key = '/library/metadata/%s/children' % self.ratingKey
|
||||
return self.fetchItems(key, **kwargs)
|
||||
return self.fetchItems(key, etag='Photo', **kwargs)
|
||||
|
||||
def photo(self, title):
|
||||
""" Returns the :class:`~plexapi.photo.Photo` that matches the specified title. """
|
||||
|
@ -58,6 +70,13 @@ class Photoalbum(PlexPartialObject):
|
|||
return photo
|
||||
raise NotFound('Unable to find photo: %s' % title)
|
||||
|
||||
def reload(self):
|
||||
""" Reload the data for this object from self.key. """
|
||||
self._initpath = self.key
|
||||
data = self._server.query(self.key)
|
||||
self._loadData(data)
|
||||
return self
|
||||
|
||||
|
||||
@utils.registerPlexObject
|
||||
class Photo(PlexPartialObject):
|
||||
|
|
Loading…
Reference in a new issue