Skip to content

Commit bc74728

Browse files
authored
Add logos to music, photos collections, and playlists (#1561)
* Add logos to artist/album/track, collection, photoalbum/photo, playlist * Add logo tests * Update all image resource tests * Add logo propery
1 parent 97c13e5 commit bc74728

File tree

11 files changed

+61
-35
lines changed

11 files changed

+61
-35
lines changed

plexapi/audio.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
from plexapi.exceptions import BadRequest
1313
from plexapi.mixins import (
1414
AdvancedSettingsMixin, SplitMergeMixin, UnmatchMatchMixin, ExtrasMixin, HubsMixin, PlayedUnplayedMixin, RatingMixin,
15-
ArtUrlMixin, ArtMixin, PosterUrlMixin, PosterMixin, SquareArtMixin, SquareArtUrlMixin, ThemeMixin, ThemeUrlMixin,
15+
ArtUrlMixin, ArtMixin, LogoMixin, LogoUrlMixin, PosterUrlMixin, PosterMixin, SquareArtMixin, SquareArtUrlMixin,
16+
ThemeMixin, ThemeUrlMixin,
1617
ArtistEditMixins, AlbumEditMixins, TrackEditMixins
1718
)
1819
from plexapi.playlist import Playlist
@@ -181,7 +182,7 @@ def sonicallySimilar(
181182
class Artist(
182183
Audio,
183184
AdvancedSettingsMixin, SplitMergeMixin, UnmatchMatchMixin, ExtrasMixin, HubsMixin, RatingMixin,
184-
ArtMixin, PosterMixin, SquareArtMixin, ThemeMixin,
185+
ArtMixin, LogoMixin, PosterMixin, SquareArtMixin, ThemeMixin,
185186
ArtistEditMixins
186187
):
187188
""" Represents a single Artist.
@@ -351,7 +352,7 @@ def metadataDirectory(self):
351352
class Album(
352353
Audio,
353354
SplitMergeMixin, UnmatchMatchMixin, RatingMixin,
354-
ArtMixin, PosterMixin, SquareArtMixin, ThemeUrlMixin,
355+
ArtMixin, LogoMixin, PosterMixin, SquareArtMixin, ThemeUrlMixin,
355356
AlbumEditMixins
356357
):
357358
""" Represents a single Album.
@@ -504,7 +505,7 @@ def metadataDirectory(self):
504505
class Track(
505506
Audio, Playable,
506507
ExtrasMixin, RatingMixin,
507-
ArtUrlMixin, PosterUrlMixin, SquareArtUrlMixin, ThemeUrlMixin,
508+
ArtUrlMixin, LogoUrlMixin, PosterUrlMixin, SquareArtUrlMixin, ThemeUrlMixin,
508509
TrackEditMixins
509510
):
510511
""" Represents a single Track.

plexapi/collection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from plexapi.library import LibrarySection, ManagedHub
99
from plexapi.mixins import (
1010
AdvancedSettingsMixin, SmartFilterMixin, HubsMixin, RatingMixin,
11-
ArtMixin, PosterMixin, SquareArtMixin, ThemeMixin,
11+
ArtMixin, LogoMixin, PosterMixin, SquareArtMixin, ThemeMixin,
1212
CollectionEditMixins
1313
)
1414
from plexapi.utils import deprecated
@@ -18,7 +18,7 @@
1818
class Collection(
1919
PlexPartialObject,
2020
AdvancedSettingsMixin, SmartFilterMixin, HubsMixin, RatingMixin,
21-
ArtMixin, PosterMixin, SquareArtMixin, ThemeMixin,
21+
ArtMixin, LogoMixin, PosterMixin, SquareArtMixin, ThemeMixin,
2222
CollectionEditMixins
2323
):
2424
""" Represents a single Collection.

plexapi/mixins.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,15 @@ def setArt(self, art):
406406
class LogoUrlMixin:
407407
""" Mixin for Plex objects that can have a logo url. """
408408

409+
@property
410+
def logo(self):
411+
""" Return the API path to the logo image. """
412+
return next((i.url for i in self.images if i.type == 'clearLogo'), None)
413+
409414
@property
410415
def logoUrl(self):
411416
""" Return the logo url for the Plex object. """
412-
image = next((i for i in self.images if i.type == 'clearLogo'), None)
413-
return self._server.url(image.url, includeToken=True) if image else None
417+
return self._server.url(self.logo, includeToken=True) if self.logo else None
414418

415419

416420
class LogoLockMixin:

plexapi/photo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from plexapi.exceptions import BadRequest
99
from plexapi.mixins import (
1010
RatingMixin,
11-
ArtUrlMixin, ArtMixin, PosterUrlMixin, PosterMixin, SquareArtMixin, SquareArtUrlMixin,
11+
ArtUrlMixin, ArtMixin, LogoMixin, LogoUrlMixin, PosterUrlMixin, PosterMixin, SquareArtMixin, SquareArtUrlMixin,
1212
PhotoalbumEditMixins, PhotoEditMixins
1313
)
1414

@@ -17,7 +17,7 @@
1717
class Photoalbum(
1818
PlexPartialObject,
1919
RatingMixin,
20-
ArtMixin, PosterMixin, SquareArtMixin,
20+
ArtMixin, LogoMixin, PosterMixin, SquareArtMixin,
2121
PhotoalbumEditMixins
2222
):
2323
""" Represents a single Photoalbum (collection of photos).
@@ -159,7 +159,7 @@ def metadataDirectory(self):
159159
class Photo(
160160
PlexPartialObject, Playable,
161161
RatingMixin,
162-
ArtUrlMixin, PosterUrlMixin, SquareArtUrlMixin,
162+
ArtUrlMixin, LogoUrlMixin, PosterUrlMixin, SquareArtUrlMixin,
163163
PhotoEditMixins
164164
):
165165
""" Represents a single Photo.

plexapi/playlist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
from plexapi.base import Playable, PlexPartialObject, cached_data_property
99
from plexapi.exceptions import BadRequest, NotFound, Unsupported
1010
from plexapi.library import LibrarySection, MusicSection
11-
from plexapi.mixins import SmartFilterMixin, ArtMixin, PosterMixin, SquareArtMixin, PlaylistEditMixins
11+
from plexapi.mixins import SmartFilterMixin, ArtMixin, LogoMixin, PosterMixin, SquareArtMixin, PlaylistEditMixins
1212
from plexapi.utils import deprecated
1313

1414

1515
@utils.registerPlexObject
1616
class Playlist(
1717
PlexPartialObject, Playable,
1818
SmartFilterMixin,
19-
ArtMixin, PosterMixin, SquareArtMixin,
19+
ArtMixin, LogoMixin, PosterMixin, SquareArtMixin,
2020
PlaylistEditMixins
2121
):
2222
""" Represents a single Playlist.

tests/test_audio.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,12 @@ def test_audio_Artist_mixins_edit_advanced_settings(artist):
104104
def test_audio_Artist_mixins_images(artist):
105105
test_mixins.lock_art(artist)
106106
test_mixins.lock_poster(artist)
107-
test_mixins.lock_square_art(artist)
107+
test_mixins.lock_squareArt(artist)
108108
test_mixins.edit_art(artist)
109109
test_mixins.edit_poster(artist)
110-
test_mixins.edit_square_art(artist)
110+
test_mixins.edit_squareArt(artist)
111111
test_mixins.attr_artUrl(artist)
112+
test_mixins.attr_logoUrl(artist)
112113
test_mixins.attr_posterUrl(artist)
113114
test_mixins.attr_squareArtUrl(artist)
114115

@@ -237,11 +238,12 @@ def test_audio_Album_artist(album):
237238
def test_audio_Album_mixins_images(album):
238239
test_mixins.lock_art(album)
239240
test_mixins.lock_poster(album)
240-
test_mixins.lock_square_art(album)
241+
test_mixins.lock_squareArt(album)
241242
test_mixins.edit_art(album)
242243
test_mixins.edit_poster(album)
243-
test_mixins.edit_square_art(album)
244+
test_mixins.edit_squareArt(album)
244245
test_mixins.attr_artUrl(album)
246+
test_mixins.attr_logoUrl(album)
245247
test_mixins.attr_posterUrl(album)
246248
test_mixins.attr_squareArtUrl(album)
247249

@@ -430,6 +432,7 @@ def test_audio_Track_sonicAdventure(account_plexpass, music):
430432

431433
def test_audio_Track_mixins_images(track):
432434
test_mixins.attr_artUrl(track)
435+
test_mixins.attr_logoUrl(track)
433436
test_mixins.attr_posterUrl(track)
434437
test_mixins.attr_squareArtUrl(track)
435438

tests/test_collection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,12 @@ def test_Collection_art(collection):
353353
def test_Collection_mixins_images(collection):
354354
test_mixins.lock_art(collection)
355355
test_mixins.lock_poster(collection)
356-
test_mixins.lock_square_art(collection)
356+
test_mixins.lock_squareArt(collection)
357357
test_mixins.edit_art(collection)
358358
test_mixins.edit_poster(collection)
359-
test_mixins.edit_square_art(collection)
359+
test_mixins.edit_squareArt(collection)
360360
test_mixins.attr_artUrl(collection)
361+
test_mixins.attr_logoUrl(collection)
361362
test_mixins.attr_posterUrl(collection)
362363
test_mixins.attr_squareArtUrl(collection)
363364

tests/test_mixins.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def lock_poster(obj):
223223
_test_mixins_lock_image(obj, "posters")
224224

225225

226-
def lock_square_art(obj):
226+
def lock_squareArt(obj):
227227
_test_mixins_lock_image(obj, "squareArts")
228228

229229

@@ -298,7 +298,7 @@ def edit_poster(obj):
298298
_test_mixins_edit_image(obj, "posters")
299299

300300

301-
def edit_square_art(obj):
301+
def edit_squareArt(obj):
302302
_test_mixins_edit_image(obj, "squareArts")
303303

304304

@@ -318,6 +318,10 @@ def attr_artUrl(obj):
318318
_test_mixins_imageUrl(obj, "art")
319319

320320

321+
def attr_logoUrl(obj):
322+
_test_mixins_imageUrl(obj, "logo")
323+
324+
321325
def attr_posterUrl(obj):
322326
_test_mixins_imageUrl(obj, "thumb")
323327

tests/test_photo.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ def test_photo_Photoalbum(photoalbum):
1717

1818
@pytest.mark.xfail(reason="Changing images fails randomly")
1919
def test_photo_Photoalbum_mixins_images(photoalbum):
20-
# test_mixins.lock_art(photoalbum) # Unlocking photoalbum artwork is broken in Plex
21-
# test_mixins.lock_poster(photoalbum) # Unlocking photoalbum poster is broken in Plex
2220
test_mixins.edit_art(photoalbum)
2321
test_mixins.edit_poster(photoalbum)
24-
test_mixins.lock_square_art(photoalbum)
22+
test_mixins.edit_squareArt(photoalbum)
23+
test_mixins.lock_art(photoalbum)
24+
test_mixins.lock_poster(photoalbum)
25+
test_mixins.lock_squareArt(photoalbum)
2526
test_mixins.attr_artUrl(photoalbum)
27+
test_mixins.attr_logoUrl(photoalbum)
2628
test_mixins.attr_posterUrl(photoalbum)
2729
test_mixins.attr_squareArtUrl(photoalbum)
2830

tests/test_playlist.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,14 @@ def test_Playlist_PlexWebURL(plex, show):
328328
def test_Playlist_mixins_images(playlist):
329329
test_mixins.lock_art(playlist)
330330
test_mixins.lock_poster(playlist)
331-
test_mixins.lock_square_art(playlist)
331+
test_mixins.lock_squareArt(playlist)
332332
test_mixins.edit_art(playlist)
333333
test_mixins.edit_poster(playlist)
334-
test_mixins.edit_square_art(playlist)
334+
test_mixins.edit_squareArt(playlist)
335+
test_mixins.attr_artUrl(playlist)
336+
test_mixins.attr_logoUrl(playlist)
337+
test_mixins.attr_posterUrl(playlist)
338+
test_mixins.attr_squareArtUrl(playlist)
335339

336340

337341
def test_Playlist_mixins_fields(playlist):

0 commit comments

Comments
 (0)