Add banner url to show tests

This commit is contained in:
JonnyWong16 2021-02-14 19:03:19 -08:00
parent bbafaee1cf
commit 8478ae6e62
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
5 changed files with 41 additions and 6 deletions

View file

@ -69,13 +69,17 @@ class Audio(PlexPartialObject):
@property @property
def thumbUrl(self): def thumbUrl(self):
""" Return url to for the thumbnail image. """ """ Return the first first thumbnail url starting on
the most specific thumbnail for that item.
"""
key = self.firstAttr('thumb', 'parentThumb', 'granparentThumb') key = self.firstAttr('thumb', 'parentThumb', 'granparentThumb')
return self._server.url(key, includeToken=True) if key else None return self._server.url(key, includeToken=True) if key else None
@property @property
def artUrl(self): def artUrl(self):
""" Return the first art url starting on the most specific for that item.""" """ Return the first first art url starting on
the most specific art for that item.
"""
art = self.firstAttr('art', 'grandparentArt') art = self.firstAttr('art', 'grandparentArt')
return self._server.url(art, includeToken=True) if art else None return self._server.url(art, includeToken=True) if art else None

View file

@ -76,7 +76,9 @@ class Video(PlexPartialObject):
@property @property
def artUrl(self): def artUrl(self):
""" Return the first first art url starting on the most specific for that item.""" """ Return the first first art url starting on
the most specific art for that item.
"""
art = self.firstAttr('art', 'grandparentArt') art = self.firstAttr('art', 'grandparentArt')
return self._server.url(art, includeToken=True) if art else None return self._server.url(art, includeToken=True) if art else None
@ -458,6 +460,11 @@ class Show(Video, ArtMixin, BannerMixin, PosterMixin, SplitMergeMixin, UnmatchMa
""" Returns True if the show is fully watched. """ """ Returns True if the show is fully watched. """
return bool(self.viewedLeafCount == self.leafCount) return bool(self.viewedLeafCount == self.leafCount)
@property
def bannerUrl(self):
""" Return the banner url for the show."""
return self._server.url(self.banner, includeToken=True) if self.banner else None
def preferences(self): def preferences(self):
""" Returns a list of :class:`~plexapi.settings.Preferences` objects. """ """ Returns a list of :class:`~plexapi.settings.Preferences` objects. """
items = [] items = []

View file

@ -381,6 +381,10 @@ def is_art(key):
return is_metadata(key, contains="/art/") return is_metadata(key, contains="/art/")
def is_banner(key):
return is_metadata(key, contains="/banner/")
def is_thumb(key): def is_thumb(key):
return is_metadata(key, contains="/thumb/") return is_metadata(key, contains="/thumb/")
@ -389,6 +393,10 @@ def is_artUrl(url):
return url.startswith(SERVER_BASEURL) and "/library/metadata/" in url and "/art/" in url return url.startswith(SERVER_BASEURL) and "/library/metadata/" in url and "/art/" in url
def is_bannerUrl(url):
return url.startswith(SERVER_BASEURL) and "/library/metadata/" in url and "/banner/" in url
def is_thumbUrl(url): def is_thumbUrl(url):
return url.startswith(SERVER_BASEURL) and "/library/metadata/" in url and "/thumb/" in url return url.startswith(SERVER_BASEURL) and "/library/metadata/" in url and "/thumb/" in url

View file

@ -179,8 +179,12 @@ def test_audio_Album_track(album, track=None):
else: else:
assert track.artUrl is None assert track.artUrl is None
assert utils.is_int(track.duration) assert utils.is_int(track.duration)
if track.grandparentArt:
assert utils.is_art(track.grandparentArt)
assert utils.is_metadata(track.grandparentKey) assert utils.is_metadata(track.grandparentKey)
assert utils.is_int(track.grandparentRatingKey) assert utils.is_int(track.grandparentRatingKey)
if track.grandparentThumb:
assert utils.is_thumb(track.grandparentThumb)
assert track.grandparentTitle == "Broke For Free" assert track.grandparentTitle == "Broke For Free"
assert int(track.index) == 1 assert int(track.index) == 1
assert utils.is_metadata(track._initpath) assert utils.is_metadata(track._initpath)
@ -273,7 +277,8 @@ def test_audio_Track_attrs(album):
assert track.artUrl is None assert track.artUrl is None
assert track.chapterSource is None assert track.chapterSource is None
assert utils.is_int(track.duration) assert utils.is_int(track.duration)
assert track.grandparentArt is None if track.grandparentArt:
assert utils.is_art(track.grandparengrandparentArt)
assert utils.is_metadata(track.grandparentKey) assert utils.is_metadata(track.grandparentKey)
assert utils.is_int(track.grandparentRatingKey) assert utils.is_int(track.grandparentRatingKey)
if track.grandparentThumb: if track.grandparentThumb:

View file

@ -559,7 +559,11 @@ def test_video_Show_attrs(show):
assert utils.is_artUrl(show.artUrl) assert utils.is_artUrl(show.artUrl)
else: else:
assert show.artUrl is None assert show.artUrl is None
assert utils.is_metadata(show.banner, contains="/banner/") if show.banner:
assert utils.is_banner(show.banner)
assert utils.is_bannerUrl(show.bannerUrl)
else:
assert show.bannerUrl is None
assert utils.is_int(show.childCount) assert utils.is_int(show.childCount)
assert show.contentRating in utils.CONTENTRATINGS assert show.contentRating in utils.CONTENTRATINGS
assert utils.is_int(show.duration, gte=1600000) assert utils.is_int(show.duration, gte=1600000)
@ -800,6 +804,10 @@ def test_video_Episode_attrs(episode):
if len(episode.directors): if len(episode.directors):
assert [i.tag for i in episode.directors] == ["Tim Van Patten"] assert [i.tag for i in episode.directors] == ["Tim Van Patten"]
assert utils.is_int(episode.duration, gte=120000) assert utils.is_int(episode.duration, gte=120000)
if episode.grandparentArt:
assert utils.is_art(episode.grandparentArt)
if episode.grandparentThumb:
assert utils.is_thumb(episode.grandparentThumb)
assert episode.grandparentTitle == "Game of Thrones" assert episode.grandparentTitle == "Game of Thrones"
assert episode.index == 1 assert episode.index == 1
assert utils.is_metadata(episode._initpath) assert utils.is_metadata(episode._initpath)
@ -809,7 +817,8 @@ def test_video_Episode_attrs(episode):
assert utils.is_int(episode.parentIndex) assert utils.is_int(episode.parentIndex)
assert utils.is_metadata(episode.parentKey) assert utils.is_metadata(episode.parentKey)
assert utils.is_int(episode.parentRatingKey) assert utils.is_int(episode.parentRatingKey)
assert utils.is_metadata(episode.parentThumb, contains="/thumb/") if episode.parentThumb:
assert utils.is_thumb(episode.parentThumb)
assert episode.rating >= 7.7 assert episode.rating >= 7.7
assert utils.is_int(episode.ratingKey) assert utils.is_int(episode.ratingKey)
assert episode._server._baseurl == utils.SERVER_BASEURL assert episode._server._baseurl == utils.SERVER_BASEURL
@ -907,6 +916,8 @@ def test_video_Season_attrs(show):
assert season.listType == "video" assert season.listType == "video"
assert utils.is_metadata(season.parentKey) assert utils.is_metadata(season.parentKey)
assert utils.is_int(season.parentRatingKey) assert utils.is_int(season.parentRatingKey)
if season.parentThumb:
assert utils.is_thumb(season.parentThumb)
assert season.parentTitle == "Game of Thrones" assert season.parentTitle == "Game of Thrones"
assert utils.is_int(season.ratingKey) assert utils.is_int(season.ratingKey)
assert season._server._baseurl == utils.SERVER_BASEURL assert season._server._baseurl == utils.SERVER_BASEURL