mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 06:04:15 +00:00
make media iterable.
they will yield the next lower level. so a show will iter a season a season will yield a episode etc.
This commit is contained in:
parent
f52957f099
commit
e402c3227b
3 changed files with 20 additions and 0 deletions
|
@ -78,6 +78,10 @@ class Artist(Audio):
|
|||
self.similar = self.findItems(data, media.Similar)
|
||||
self.collections = self.findItems(data, media.Collection)
|
||||
|
||||
def __iter__(self):
|
||||
for album in self.albums():
|
||||
yield album
|
||||
|
||||
def album(self, title):
|
||||
""" Returns the :class:`~plexapi.audio.Album` that matches the specified title.
|
||||
|
||||
|
@ -151,6 +155,10 @@ class Album(Audio):
|
|||
TAG = 'Directory'
|
||||
TYPE = 'album'
|
||||
|
||||
def __iter__(self):
|
||||
for track in self.tracks:
|
||||
yield track
|
||||
|
||||
def _loadData(self, data):
|
||||
""" Load attribute values from Plex XML response. """
|
||||
Audio._loadData(self, data)
|
||||
|
|
|
@ -272,6 +272,9 @@ class PlexPartialObject(PlexObject):
|
|||
def __hash__(self):
|
||||
return hash(repr(self))
|
||||
|
||||
def __iter__(self):
|
||||
yield self
|
||||
|
||||
def __getattribute__(self, attr):
|
||||
# Dragons inside.. :-/
|
||||
value = utils.getattributeOrNone(PlexPartialObject, self, attr)
|
||||
|
|
|
@ -24,6 +24,7 @@ class Video(PlexPartialObject):
|
|||
updatedAt (datatime): Datetime this item was updated.
|
||||
viewCount (int): Count of times this item was accessed.
|
||||
"""
|
||||
|
||||
def _loadData(self, data):
|
||||
""" Load attribute values from Plex XML response. """
|
||||
self._data = data
|
||||
|
@ -214,6 +215,10 @@ class Show(Video):
|
|||
TAG = 'Directory'
|
||||
TYPE = 'show'
|
||||
|
||||
def __iter__(self):
|
||||
for season in self.seasons():
|
||||
yield season
|
||||
|
||||
def _loadData(self, data):
|
||||
""" Load attribute values from Plex XML response. """
|
||||
Video._loadData(self, data)
|
||||
|
@ -335,6 +340,10 @@ class Season(Video):
|
|||
TAG = 'Directory'
|
||||
TYPE = 'season'
|
||||
|
||||
def __iter__(self):
|
||||
for episode in self.episodes():
|
||||
yield episode
|
||||
|
||||
def _loadData(self, data):
|
||||
""" Load attribute values from Plex XML response. """
|
||||
Video._loadData(self, data)
|
||||
|
|
Loading…
Reference in a new issue