Skip to content

Commit

Permalink
Merge pull request #390 from pkkid/posters
Browse files Browse the repository at this point in the history
posters
  • Loading branch information
Hellowlol authored Nov 6, 2019
2 parents 209f9bd + be09f44 commit 4ea81af
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
17 changes: 17 additions & 0 deletions plexapi/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,23 @@ class Mood(MediaTag):
FILTER = 'mood'


@utils.registerPlexObject
class Poster(PlexObject):
""" Represents a Poster.
Attributes:
TAG (str): 'Photo'
"""
TAG = 'Photo'

def _loadData(self, data):
self._data = data
self.key = data.attrib.get('key')
self.ratingKey = data.attrib.get('ratingKey')
self.selected = data.attrib.get('selected')
self.thumb = data.attrib.get('thumb')


@utils.registerPlexObject
class Producer(MediaTag):
""" Represents a single Producer media tag.
Expand Down
5 changes: 5 additions & 0 deletions plexapi/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ def _defaultSyncTitle(self):
""" Returns str, default title for a new syncItem. """
return self.title

def posters(self):
""" Returns list of available poster objects. :class:`~plexapi.media.Poster`:"""

return self.fetchItems('%s/posters' % self.key, cls=media.Poster)

def sync(self, videoQuality, client=None, clientId=None, limit=None, unwatched=False, title=None):
""" Add current video (movie, tv-show, season or episode) as sync item for specified device.
See :func:`plexapi.myplex.MyPlexAccount.sync()` for possible exceptions.
Expand Down
1 change: 1 addition & 0 deletions tests/test_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def test_video_Movie_attrs(movies):
assert [i.tag for i in movie.directors] == ['Nina Paley']
assert movie.duration >= 160000
assert movie.fields == []
assert movie.posters()
assert sorted([i.tag for i in movie.genres]) == ['Animation', 'Comedy', 'Fantasy', 'Musical', 'Romance']
assert movie.guid == 'com.plexapp.agents.imdb://tt1172203?lang=en'
assert utils.is_metadata(movie._initpath)
Expand Down

0 comments on commit 4ea81af

Please sign in to comment.