diff --git a/plexapi/audio.py b/plexapi/audio.py index 0b8b6d4ab..7686a37e4 100644 --- a/plexapi/audio.py +++ b/plexapi/audio.py @@ -12,7 +12,8 @@ from plexapi.exceptions import BadRequest from plexapi.mixins import ( AdvancedSettingsMixin, SplitMergeMixin, UnmatchMatchMixin, ExtrasMixin, HubsMixin, PlayedUnplayedMixin, RatingMixin, - ArtUrlMixin, ArtMixin, PosterUrlMixin, PosterMixin, SquareArtMixin, SquareArtUrlMixin, ThemeMixin, ThemeUrlMixin, + ArtUrlMixin, ArtMixin, LogoMixin, LogoUrlMixin, PosterUrlMixin, PosterMixin, SquareArtMixin, SquareArtUrlMixin, + ThemeMixin, ThemeUrlMixin, ArtistEditMixins, AlbumEditMixins, TrackEditMixins ) from plexapi.playlist import Playlist @@ -181,7 +182,7 @@ def sonicallySimilar( class Artist( Audio, AdvancedSettingsMixin, SplitMergeMixin, UnmatchMatchMixin, ExtrasMixin, HubsMixin, RatingMixin, - ArtMixin, PosterMixin, SquareArtMixin, ThemeMixin, + ArtMixin, LogoMixin, PosterMixin, SquareArtMixin, ThemeMixin, ArtistEditMixins ): """ Represents a single Artist. @@ -351,7 +352,7 @@ def metadataDirectory(self): class Album( Audio, SplitMergeMixin, UnmatchMatchMixin, RatingMixin, - ArtMixin, PosterMixin, SquareArtMixin, ThemeUrlMixin, + ArtMixin, LogoMixin, PosterMixin, SquareArtMixin, ThemeUrlMixin, AlbumEditMixins ): """ Represents a single Album. @@ -504,7 +505,7 @@ def metadataDirectory(self): class Track( Audio, Playable, ExtrasMixin, RatingMixin, - ArtUrlMixin, PosterUrlMixin, SquareArtUrlMixin, ThemeUrlMixin, + ArtUrlMixin, LogoUrlMixin, PosterUrlMixin, SquareArtUrlMixin, ThemeUrlMixin, TrackEditMixins ): """ Represents a single Track. diff --git a/plexapi/collection.py b/plexapi/collection.py index b35514fc6..75d76445d 100644 --- a/plexapi/collection.py +++ b/plexapi/collection.py @@ -8,7 +8,7 @@ from plexapi.library import LibrarySection, ManagedHub from plexapi.mixins import ( AdvancedSettingsMixin, SmartFilterMixin, HubsMixin, RatingMixin, - ArtMixin, PosterMixin, SquareArtMixin, ThemeMixin, + ArtMixin, LogoMixin, PosterMixin, SquareArtMixin, ThemeMixin, CollectionEditMixins ) from plexapi.utils import deprecated @@ -18,7 +18,7 @@ class Collection( PlexPartialObject, AdvancedSettingsMixin, SmartFilterMixin, HubsMixin, RatingMixin, - ArtMixin, PosterMixin, SquareArtMixin, ThemeMixin, + ArtMixin, LogoMixin, PosterMixin, SquareArtMixin, ThemeMixin, CollectionEditMixins ): """ Represents a single Collection. diff --git a/plexapi/mixins.py b/plexapi/mixins.py index 37a0449ec..b9710e43c 100644 --- a/plexapi/mixins.py +++ b/plexapi/mixins.py @@ -406,11 +406,15 @@ def setArt(self, art): class LogoUrlMixin: """ Mixin for Plex objects that can have a logo url. """ + @property + def logo(self): + """ Return the API path to the logo image. """ + return next((i.url for i in self.images if i.type == 'clearLogo'), None) + @property def logoUrl(self): """ Return the logo url for the Plex object. """ - image = next((i for i in self.images if i.type == 'clearLogo'), None) - return self._server.url(image.url, includeToken=True) if image else None + return self._server.url(self.logo, includeToken=True) if self.logo else None class LogoLockMixin: diff --git a/plexapi/photo.py b/plexapi/photo.py index 478f33c93..adb44d5eb 100644 --- a/plexapi/photo.py +++ b/plexapi/photo.py @@ -8,7 +8,7 @@ from plexapi.exceptions import BadRequest from plexapi.mixins import ( RatingMixin, - ArtUrlMixin, ArtMixin, PosterUrlMixin, PosterMixin, SquareArtMixin, SquareArtUrlMixin, + ArtUrlMixin, ArtMixin, LogoMixin, LogoUrlMixin, PosterUrlMixin, PosterMixin, SquareArtMixin, SquareArtUrlMixin, PhotoalbumEditMixins, PhotoEditMixins ) @@ -17,7 +17,7 @@ class Photoalbum( PlexPartialObject, RatingMixin, - ArtMixin, PosterMixin, SquareArtMixin, + ArtMixin, LogoMixin, PosterMixin, SquareArtMixin, PhotoalbumEditMixins ): """ Represents a single Photoalbum (collection of photos). @@ -159,7 +159,7 @@ def metadataDirectory(self): class Photo( PlexPartialObject, Playable, RatingMixin, - ArtUrlMixin, PosterUrlMixin, SquareArtUrlMixin, + ArtUrlMixin, LogoUrlMixin, PosterUrlMixin, SquareArtUrlMixin, PhotoEditMixins ): """ Represents a single Photo. diff --git a/plexapi/playlist.py b/plexapi/playlist.py index 7c05f1097..8fe0625c6 100644 --- a/plexapi/playlist.py +++ b/plexapi/playlist.py @@ -8,7 +8,7 @@ from plexapi.base import Playable, PlexPartialObject, cached_data_property from plexapi.exceptions import BadRequest, NotFound, Unsupported from plexapi.library import LibrarySection, MusicSection -from plexapi.mixins import SmartFilterMixin, ArtMixin, PosterMixin, SquareArtMixin, PlaylistEditMixins +from plexapi.mixins import SmartFilterMixin, ArtMixin, LogoMixin, PosterMixin, SquareArtMixin, PlaylistEditMixins from plexapi.utils import deprecated @@ -16,7 +16,7 @@ class Playlist( PlexPartialObject, Playable, SmartFilterMixin, - ArtMixin, PosterMixin, SquareArtMixin, + ArtMixin, LogoMixin, PosterMixin, SquareArtMixin, PlaylistEditMixins ): """ Represents a single Playlist. diff --git a/tests/test_audio.py b/tests/test_audio.py index 8560b149a..91be580ec 100644 --- a/tests/test_audio.py +++ b/tests/test_audio.py @@ -104,11 +104,12 @@ def test_audio_Artist_mixins_edit_advanced_settings(artist): def test_audio_Artist_mixins_images(artist): test_mixins.lock_art(artist) test_mixins.lock_poster(artist) - test_mixins.lock_square_art(artist) + test_mixins.lock_squareArt(artist) test_mixins.edit_art(artist) test_mixins.edit_poster(artist) - test_mixins.edit_square_art(artist) + test_mixins.edit_squareArt(artist) test_mixins.attr_artUrl(artist) + test_mixins.attr_logoUrl(artist) test_mixins.attr_posterUrl(artist) test_mixins.attr_squareArtUrl(artist) @@ -237,11 +238,12 @@ def test_audio_Album_artist(album): def test_audio_Album_mixins_images(album): test_mixins.lock_art(album) test_mixins.lock_poster(album) - test_mixins.lock_square_art(album) + test_mixins.lock_squareArt(album) test_mixins.edit_art(album) test_mixins.edit_poster(album) - test_mixins.edit_square_art(album) + test_mixins.edit_squareArt(album) test_mixins.attr_artUrl(album) + test_mixins.attr_logoUrl(album) test_mixins.attr_posterUrl(album) test_mixins.attr_squareArtUrl(album) @@ -430,6 +432,7 @@ def test_audio_Track_sonicAdventure(account_plexpass, music): def test_audio_Track_mixins_images(track): test_mixins.attr_artUrl(track) + test_mixins.attr_logoUrl(track) test_mixins.attr_posterUrl(track) test_mixins.attr_squareArtUrl(track) diff --git a/tests/test_collection.py b/tests/test_collection.py index 11e7daf0e..03632530c 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -353,11 +353,12 @@ def test_Collection_art(collection): def test_Collection_mixins_images(collection): test_mixins.lock_art(collection) test_mixins.lock_poster(collection) - test_mixins.lock_square_art(collection) + test_mixins.lock_squareArt(collection) test_mixins.edit_art(collection) test_mixins.edit_poster(collection) - test_mixins.edit_square_art(collection) + test_mixins.edit_squareArt(collection) test_mixins.attr_artUrl(collection) + test_mixins.attr_logoUrl(collection) test_mixins.attr_posterUrl(collection) test_mixins.attr_squareArtUrl(collection) diff --git a/tests/test_mixins.py b/tests/test_mixins.py index c507edb6f..f80fa5479 100644 --- a/tests/test_mixins.py +++ b/tests/test_mixins.py @@ -223,7 +223,7 @@ def lock_poster(obj): _test_mixins_lock_image(obj, "posters") -def lock_square_art(obj): +def lock_squareArt(obj): _test_mixins_lock_image(obj, "squareArts") @@ -298,7 +298,7 @@ def edit_poster(obj): _test_mixins_edit_image(obj, "posters") -def edit_square_art(obj): +def edit_squareArt(obj): _test_mixins_edit_image(obj, "squareArts") @@ -318,6 +318,10 @@ def attr_artUrl(obj): _test_mixins_imageUrl(obj, "art") +def attr_logoUrl(obj): + _test_mixins_imageUrl(obj, "logo") + + def attr_posterUrl(obj): _test_mixins_imageUrl(obj, "thumb") diff --git a/tests/test_photo.py b/tests/test_photo.py index 3c4449ae6..96fa7b389 100644 --- a/tests/test_photo.py +++ b/tests/test_photo.py @@ -17,12 +17,14 @@ def test_photo_Photoalbum(photoalbum): @pytest.mark.xfail(reason="Changing images fails randomly") def test_photo_Photoalbum_mixins_images(photoalbum): - # test_mixins.lock_art(photoalbum) # Unlocking photoalbum artwork is broken in Plex - # test_mixins.lock_poster(photoalbum) # Unlocking photoalbum poster is broken in Plex test_mixins.edit_art(photoalbum) test_mixins.edit_poster(photoalbum) - test_mixins.lock_square_art(photoalbum) + test_mixins.edit_squareArt(photoalbum) + test_mixins.lock_art(photoalbum) + test_mixins.lock_poster(photoalbum) + test_mixins.lock_squareArt(photoalbum) test_mixins.attr_artUrl(photoalbum) + test_mixins.attr_logoUrl(photoalbum) test_mixins.attr_posterUrl(photoalbum) test_mixins.attr_squareArtUrl(photoalbum) diff --git a/tests/test_playlist.py b/tests/test_playlist.py index a40e8094d..f1c2f5f13 100644 --- a/tests/test_playlist.py +++ b/tests/test_playlist.py @@ -328,10 +328,14 @@ def test_Playlist_PlexWebURL(plex, show): def test_Playlist_mixins_images(playlist): test_mixins.lock_art(playlist) test_mixins.lock_poster(playlist) - test_mixins.lock_square_art(playlist) + test_mixins.lock_squareArt(playlist) test_mixins.edit_art(playlist) test_mixins.edit_poster(playlist) - test_mixins.edit_square_art(playlist) + test_mixins.edit_squareArt(playlist) + test_mixins.attr_artUrl(playlist) + test_mixins.attr_logoUrl(playlist) + test_mixins.attr_posterUrl(playlist) + test_mixins.attr_squareArtUrl(playlist) def test_Playlist_mixins_fields(playlist): diff --git a/tests/test_video.py b/tests/test_video.py index f3b7b2d7c..0c8ff6e93 100644 --- a/tests/test_video.py +++ b/tests/test_video.py @@ -695,10 +695,14 @@ def test_video_Movie_mixins_edit_advanced_settings(movie): def test_video_Movie_mixins_images(movie): test_mixins.lock_art(movie) test_mixins.lock_poster(movie) - test_mixins.lock_square_art(movie) + test_mixins.lock_squareArt(movie) test_mixins.edit_art(movie) test_mixins.edit_poster(movie) - test_mixins.edit_square_art(movie) + test_mixins.edit_squareArt(movie) + test_mixins.attr_artUrl(movie) + test_mixins.attr_logoUrl(movie) + test_mixins.attr_posterUrl(movie) + test_mixins.attr_squareArtUrl(movie) def test_video_Movie_mixins_themes(movie): @@ -964,11 +968,12 @@ def test_video_Show_mixins_edit_advanced_settings(show): def test_video_Show_mixins_images(show): test_mixins.lock_art(show) test_mixins.lock_poster(show) - test_mixins.lock_square_art(show) + test_mixins.lock_squareArt(show) test_mixins.edit_art(show) test_mixins.edit_poster(show) - test_mixins.edit_square_art(show) + test_mixins.edit_squareArt(show) test_mixins.attr_artUrl(show) + test_mixins.attr_logoUrl(show) test_mixins.attr_posterUrl(show) test_mixins.attr_squareArtUrl(show) @@ -1171,11 +1176,12 @@ def test_video_Season_mixins_images(show): season = show.season(season=1) test_mixins.lock_art(season) test_mixins.lock_poster(season) - test_mixins.lock_square_art(season) + test_mixins.lock_squareArt(season) test_mixins.edit_art(season) test_mixins.edit_poster(season) - test_mixins.edit_square_art(season) + test_mixins.edit_squareArt(season) test_mixins.attr_artUrl(season) + test_mixins.attr_logoUrl(season) test_mixins.attr_posterUrl(season) test_mixins.attr_squareArtUrl(season) @@ -1392,11 +1398,12 @@ def test_video_Episode_unwatched(tvshows): def test_video_Episode_mixins_images(episode): test_mixins.lock_art(episode) test_mixins.lock_poster(episode) - test_mixins.lock_square_art(episode) - # test_mixins.edit_art(episode) # Uploading episode artwork is broken in Plex + test_mixins.lock_squareArt(episode) + test_mixins.edit_art(episode) test_mixins.edit_poster(episode) - test_mixins.edit_square_art(episode) + test_mixins.edit_squareArt(episode) test_mixins.attr_artUrl(episode) + test_mixins.attr_logoUrl(episode) test_mixins.attr_posterUrl(episode) test_mixins.attr_squareArtUrl(episode)