Skip to content

Commit 1a0eb3c

Browse files
authored
Add UltraBlurColors objects (#1454)
* Add UltraBlurColors * Test UltraBlurColors * Test UltraBlurColors attributes * Fix tests
1 parent 075e7d7 commit 1a0eb3c

File tree

7 files changed

+51
-0
lines changed

7 files changed

+51
-0
lines changed

plexapi/audio.py

+4
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ class Artist(
193193
similar (List<:class:`~plexapi.media.Similar`>): List of similar objects.
194194
styles (List<:class:`~plexapi.media.Style`>): List of style objects.
195195
theme (str): URL to theme resource (/library/metadata/<ratingkey>/theme/<themeid>).
196+
ultraBlurColors (:class:`~plexapi.media.UltraBlurColors`): Ultra blur color object.
196197
"""
197198
TAG = 'Directory'
198199
TYPE = 'artist'
@@ -213,6 +214,7 @@ def _loadData(self, data):
213214
self.similar = self.findItems(data, media.Similar)
214215
self.styles = self.findItems(data, media.Style)
215216
self.theme = data.attrib.get('theme')
217+
self.ultraBlurColors = self.findItem(data, media.UltraBlurColors)
216218

217219
def __iter__(self):
218220
for album in self.albums():
@@ -340,6 +342,7 @@ class Album(
340342
studio (str): Studio that released the album.
341343
styles (List<:class:`~plexapi.media.Style`>): List of style objects.
342344
subformats (List<:class:`~plexapi.media.Subformat`>): List of subformat objects.
345+
ultraBlurColors (:class:`~plexapi.media.UltraBlurColors`): Ultra blur color object.
343346
viewedLeafCount (int): Number of items marked as played in the album view.
344347
year (int): Year the album was released.
345348
"""
@@ -369,6 +372,7 @@ def _loadData(self, data):
369372
self.studio = data.attrib.get('studio')
370373
self.styles = self.findItems(data, media.Style)
371374
self.subformats = self.findItems(data, media.Subformat)
375+
self.ultraBlurColors = self.findItem(data, media.UltraBlurColors)
372376
self.viewedLeafCount = utils.cast(int, data.attrib.get('viewedLeafCount'))
373377
self.year = utils.cast(int, data.attrib.get('year'))
374378

plexapi/collection.py

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class Collection(
6060
title (str): Name of the collection.
6161
titleSort (str): Title to use when sorting (defaults to title).
6262
type (str): 'collection'
63+
ultraBlurColors (:class:`~plexapi.media.UltraBlurColors`): Ultra blur color object.
6364
updatedAt (datetime): Datetime the collection was updated.
6465
userRating (float): Rating of the collection (0.0 - 10.0) equaling (0 stars - 5 stars).
6566
"""
@@ -102,6 +103,7 @@ def _loadData(self, data):
102103
self.title = data.attrib.get('title')
103104
self.titleSort = data.attrib.get('titleSort', self.title)
104105
self.type = data.attrib.get('type')
106+
self.ultraBlurColors = self.findItem(data, media.UltraBlurColors)
105107
self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt'))
106108
self.userRating = utils.cast(float, data.attrib.get('userRating'))
107109
self._items = None # cache for self.items

plexapi/media.py

+22
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,28 @@ def _loadData(self, data):
10031003
self.text = data.attrib.get('text')
10041004

10051005

1006+
@utils.registerPlexObject
1007+
class UltraBlurColors(PlexObject):
1008+
""" Represents a single UltraBlurColors media tag.
1009+
1010+
Attributes:
1011+
TAG (str): 'UltraBlurColors'
1012+
bottomLeft (str): The bottom left hex color.
1013+
bottomRight (str): The bottom right hex color.
1014+
topLeft (str): The top left hex color.
1015+
topRight (str): The top right hex color.
1016+
"""
1017+
TAG = 'UltraBlurColors'
1018+
1019+
def _loadData(self, data):
1020+
""" Load attribute values from Plex XML response. """
1021+
self._data = data
1022+
self.bottomLeft = data.attrib.get('bottomLeft')
1023+
self.bottomRight = data.attrib.get('bottomRight')
1024+
self.topLeft = data.attrib.get('topLeft')
1025+
self.topRight = data.attrib.get('topRight')
1026+
1027+
10061028
class BaseResource(PlexObject):
10071029
""" Base class for all Art, Poster, and Theme objects.
10081030

plexapi/video.py

+8
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ class Movie(
375375
studio (str): Studio that created movie (Di Bonaventura Pictures; 21 Laps Entertainment).
376376
tagline (str): Movie tag line (Back 2 Work; Who says men can't change?).
377377
theme (str): URL to theme resource (/library/metadata/<ratingkey>/theme/<themeid>).
378+
ultraBlurColors (:class:`~plexapi.media.UltraBlurColors`): Ultra blur color object.
378379
useOriginalTitle (int): Setting that indicates if the original title is used for the movie
379380
(-1 = Library default, 0 = No, 1 = Yes).
380381
viewOffset (int): View offset in milliseconds.
@@ -420,6 +421,7 @@ def _loadData(self, data):
420421
self.studio = data.attrib.get('studio')
421422
self.tagline = data.attrib.get('tagline')
422423
self.theme = data.attrib.get('theme')
424+
self.ultraBlurColors = self.findItem(data, media.UltraBlurColors)
423425
self.useOriginalTitle = utils.cast(int, data.attrib.get('useOriginalTitle', '-1'))
424426
self.viewOffset = utils.cast(int, data.attrib.get('viewOffset', 0))
425427
self.writers = self.findItems(data, media.Writer)
@@ -543,6 +545,7 @@ class Show(
543545
(-1 = Account default, 0 = Manually selected, 1 = Shown with foreign audio, 2 = Always enabled).
544546
tagline (str): Show tag line.
545547
theme (str): URL to theme resource (/library/metadata/<ratingkey>/theme/<themeid>).
548+
ultraBlurColors (:class:`~plexapi.media.UltraBlurColors`): Ultra blur color object.
546549
useOriginalTitle (int): Setting that indicates if the original title is used for the show
547550
(-1 = Library default, 0 = No, 1 = Yes).
548551
viewedLeafCount (int): Number of items marked as played in the show view.
@@ -592,6 +595,7 @@ def _loadData(self, data):
592595
self.subtitleMode = utils.cast(int, data.attrib.get('subtitleMode', '-1'))
593596
self.tagline = data.attrib.get('tagline')
594597
self.theme = data.attrib.get('theme')
598+
self.ultraBlurColors = self.findItem(data, media.UltraBlurColors)
595599
self.useOriginalTitle = utils.cast(int, data.attrib.get('useOriginalTitle', '-1'))
596600
self.viewedLeafCount = utils.cast(int, data.attrib.get('viewedLeafCount'))
597601
self.year = utils.cast(int, data.attrib.get('year'))
@@ -735,6 +739,7 @@ class Season(
735739
subtitleLanguage (str): Setting that indicates the preferred subtitle language.
736740
subtitleMode (int): Setting that indicates the auto-select subtitle mode.
737741
(-1 = Series default, 0 = Manually selected, 1 = Shown with foreign audio, 2 = Always enabled).
742+
ultraBlurColors (:class:`~plexapi.media.UltraBlurColors`): Ultra blur color object.
738743
viewedLeafCount (int): Number of items marked as played in the season view.
739744
year (int): Year the season was released.
740745
"""
@@ -766,6 +771,7 @@ def _loadData(self, data):
766771
self.ratings = self.findItems(data, media.Rating)
767772
self.subtitleLanguage = data.attrib.get('subtitleLanguage', '')
768773
self.subtitleMode = utils.cast(int, data.attrib.get('subtitleMode', '-1'))
774+
self.ultraBlurColors = self.findItem(data, media.UltraBlurColors)
769775
self.viewedLeafCount = utils.cast(int, data.attrib.get('viewedLeafCount'))
770776
self.year = utils.cast(int, data.attrib.get('year'))
771777

@@ -914,6 +920,7 @@ class Episode(
914920
skipParent (bool): True if the show's seasons are set to hidden.
915921
sourceURI (str): Remote server URI (server://<machineIdentifier>/com.plexapp.plugins.library)
916922
(remote playlist item only).
923+
ultraBlurColors (:class:`~plexapi.media.UltraBlurColors`): Ultra blur color object.
917924
viewOffset (int): View offset in milliseconds.
918925
writers (List<:class:`~plexapi.media.Writer`>): List of writers objects.
919926
year (int): Year the episode was released.
@@ -958,6 +965,7 @@ def _loadData(self, data):
958965
self.roles = self.findItems(data, media.Role)
959966
self.skipParent = utils.cast(bool, data.attrib.get('skipParent', '0'))
960967
self.sourceURI = data.attrib.get('source') # remote playlist item
968+
self.ultraBlurColors = self.findItem(data, media.UltraBlurColors)
961969
self.viewOffset = utils.cast(int, data.attrib.get('viewOffset', 0))
962970
self.writers = self.findItems(data, media.Writer)
963971
self.year = utils.cast(int, data.attrib.get('year'))

tests/test_audio.py

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def test_audio_Artist_attr(artist):
4444
assert artist.title == "Broke For Free"
4545
assert artist.titleSort == "Broke For Free"
4646
assert artist.type == "artist"
47+
assert artist.ultraBlurColors is None
4748
assert utils.is_datetime(artist.updatedAt)
4849
assert utils.is_int(artist.viewCount, gte=0)
4950

@@ -185,6 +186,7 @@ def test_audio_Album_attrs(album):
185186
assert album.title == "Layers"
186187
assert album.titleSort == "Layers"
187188
assert album.type == "album"
189+
assert album.ultraBlurColors is not None
188190
assert utils.is_datetime(album.updatedAt)
189191
assert utils.is_int(album.viewCount, gte=0)
190192
assert album.year in (2012,)

tests/test_collection.py

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def test_Collection_attrs(collection):
4040
assert collection.title == "Test Collection"
4141
assert collection.titleSort == collection.title
4242
assert collection.type == "collection"
43+
assert utils.is_composite(collection.thumb, prefix="/library/collections") and collection.ultraBlurColors is None
4344
assert utils.is_datetime(collection.updatedAt)
4445
assert collection.listType == "video"
4546
assert collection.metadataType == collection.subtype

tests/test_video.py

+12
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def test_video_Movie_attrs(movies):
102102
assert movie.title == "Sita Sings the Blues"
103103
assert movie.titleSort == "Sita Sings the Blues"
104104
assert movie.type == "movie"
105+
assert movie.ultraBlurColors is not None
105106
assert movie.updatedAt > datetime(2017, 1, 1)
106107
assert movie.useOriginalTitle == -1
107108
assert movie.userRating is None
@@ -669,6 +670,14 @@ def test_video_Movie_batchEdits(movie):
669670
movie.saveEdits()
670671

671672

673+
def test_video_Movie_ultraBlurColors(movie):
674+
ultraBlurColors = movie.ultraBlurColors
675+
assert ultraBlurColors.bottomLeft
676+
assert ultraBlurColors.bottomRight
677+
assert ultraBlurColors.topLeft
678+
assert ultraBlurColors.topRight
679+
680+
672681
def test_video_Movie_mixins_edit_advanced_settings(movie):
673682
test_mixins.edit_advanced_settings(movie)
674683

@@ -817,6 +826,7 @@ def test_video_Show_attrs(show):
817826
assert show.title == "Game of Thrones"
818827
assert show.titleSort == "Game of Thrones"
819828
assert show.type == "show"
829+
assert show.ultraBlurColors is not None
820830
assert show.useOriginalTitle == -1
821831
assert show.userRating is None
822832
assert utils.is_datetime(show.updatedAt)
@@ -1044,6 +1054,7 @@ def test_video_Season_attrs(show):
10441054
assert season.title == "Season 1"
10451055
assert season.titleSort == "Season 1"
10461056
assert season.type == "season"
1057+
assert season.ultraBlurColors is not None
10471058
assert utils.is_datetime(season.updatedAt)
10481059
assert utils.is_int(season.viewCount, gte=0)
10491060
assert utils.is_int(season.viewedLeafCount, gte=0)
@@ -1247,6 +1258,7 @@ def test_video_Episode_attrs(episode):
12471258
assert episode.title == "Winter Is Coming"
12481259
assert episode.titleSort == "Winter Is Coming"
12491260
assert episode.type == "episode"
1261+
assert episode.ultraBlurColors is not None
12501262
assert utils.is_datetime(episode.updatedAt)
12511263
assert episode.userRating is None
12521264
assert utils.is_int(episode.viewCount, gte=0)

0 commit comments

Comments
 (0)