Separate Poster and Art objects

This commit is contained in:
JonnyWong16 2021-01-24 11:09:42 -08:00
parent 4da40789ea
commit 48c41a1c68
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
2 changed files with 21 additions and 8 deletions

View file

@ -534,8 +534,8 @@ class PlexPartialObject(PlexObject):
def posters(self):
""" Returns list of available poster objects. :class:`~plexapi.media.Poster`. """
return self.fetchItems('%s/posters' % self.key)
from plexapi.media import Poster
return self.fetchItems('/library/metadata/%s/posters' % self.ratingKey, cls=Poster)
def uploadPoster(self, url=None, filepath=None):
""" Upload poster from url or filepath. :class:`~plexapi.media.Poster` to :class:`~plexapi.video.Video`. """
@ -553,8 +553,8 @@ class PlexPartialObject(PlexObject):
def arts(self):
""" Returns list of available art objects. :class:`~plexapi.media.Poster`. """
return self.fetchItems('%s/arts' % self.key)
from plexapi.media import Art
return self.fetchItems('/library/metadata/%s/arts' % self.ratingKey, cls=Art)
def uploadArt(self, url=None, filepath=None):
""" Upload art from url or filepath. :class:`~plexapi.media.Poster` to :class:`~plexapi.video.Video`. """

View file

@ -614,20 +614,25 @@ class Style(MediaTag):
FILTER = 'style'
@utils.registerPlexObject
class Poster(PlexObject):
""" Represents a Poster.
class BasePosterArt(PlexObject):
""" Base class for all Poster and Art objects.
Attributes:
TAG (str): 'Photo'
key (str): API URL (/library/metadata/<ratingkey>).
provider (str): The source of the poster or art.
ratingKey (str): Unique key identifying the poster or art.
selected (bool): True if the poster or art is currently selected.
thumb (str): The URL to retrieve the poster or art thumbnail.
"""
TAG = 'Photo'
def _loadData(self, data):
self._data = data
self.key = data.attrib.get('key')
self.provider = data.attrib.get('provider')
self.ratingKey = data.attrib.get('ratingKey')
self.selected = data.attrib.get('selected')
self.selected = cast(bool, data.attrib.get('selected'))
self.thumb = data.attrib.get('thumb')
def select(self):
@ -639,6 +644,14 @@ class Poster(PlexObject):
pass
class Poster(BasePosterArt):
""" Represents a single Poster object. """
class Art(BasePosterArt):
""" Represents a single Art object. """
@utils.registerPlexObject
class Producer(MediaTag):
""" Represents a single Producer media tag.