Skip to content

Commit

Permalink
Add UltraBlurColors objects (#1454)
Browse files Browse the repository at this point in the history
* Add UltraBlurColors

* Test UltraBlurColors

* Test UltraBlurColors attributes

* Fix tests
  • Loading branch information
JonnyWong16 authored Aug 18, 2024
1 parent 075e7d7 commit 1a0eb3c
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plexapi/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ class Artist(
similar (List<:class:`~plexapi.media.Similar`>): List of similar objects.
styles (List<:class:`~plexapi.media.Style`>): List of style objects.
theme (str): URL to theme resource (/library/metadata/<ratingkey>/theme/<themeid>).
ultraBlurColors (:class:`~plexapi.media.UltraBlurColors`): Ultra blur color object.
"""
TAG = 'Directory'
TYPE = 'artist'
Expand All @@ -213,6 +214,7 @@ def _loadData(self, data):
self.similar = self.findItems(data, media.Similar)
self.styles = self.findItems(data, media.Style)
self.theme = data.attrib.get('theme')
self.ultraBlurColors = self.findItem(data, media.UltraBlurColors)

def __iter__(self):
for album in self.albums():
Expand Down Expand Up @@ -340,6 +342,7 @@ class Album(
studio (str): Studio that released the album.
styles (List<:class:`~plexapi.media.Style`>): List of style objects.
subformats (List<:class:`~plexapi.media.Subformat`>): List of subformat objects.
ultraBlurColors (:class:`~plexapi.media.UltraBlurColors`): Ultra blur color object.
viewedLeafCount (int): Number of items marked as played in the album view.
year (int): Year the album was released.
"""
Expand Down Expand Up @@ -369,6 +372,7 @@ def _loadData(self, data):
self.studio = data.attrib.get('studio')
self.styles = self.findItems(data, media.Style)
self.subformats = self.findItems(data, media.Subformat)
self.ultraBlurColors = self.findItem(data, media.UltraBlurColors)
self.viewedLeafCount = utils.cast(int, data.attrib.get('viewedLeafCount'))
self.year = utils.cast(int, data.attrib.get('year'))

Expand Down
2 changes: 2 additions & 0 deletions plexapi/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Collection(
title (str): Name of the collection.
titleSort (str): Title to use when sorting (defaults to title).
type (str): 'collection'
ultraBlurColors (:class:`~plexapi.media.UltraBlurColors`): Ultra blur color object.
updatedAt (datetime): Datetime the collection was updated.
userRating (float): Rating of the collection (0.0 - 10.0) equaling (0 stars - 5 stars).
"""
Expand Down Expand Up @@ -102,6 +103,7 @@ def _loadData(self, data):
self.title = data.attrib.get('title')
self.titleSort = data.attrib.get('titleSort', self.title)
self.type = data.attrib.get('type')
self.ultraBlurColors = self.findItem(data, media.UltraBlurColors)
self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt'))
self.userRating = utils.cast(float, data.attrib.get('userRating'))
self._items = None # cache for self.items
Expand Down
22 changes: 22 additions & 0 deletions plexapi/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,28 @@ def _loadData(self, data):
self.text = data.attrib.get('text')


@utils.registerPlexObject
class UltraBlurColors(PlexObject):
""" Represents a single UltraBlurColors media tag.
Attributes:
TAG (str): 'UltraBlurColors'
bottomLeft (str): The bottom left hex color.
bottomRight (str): The bottom right hex color.
topLeft (str): The top left hex color.
topRight (str): The top right hex color.
"""
TAG = 'UltraBlurColors'

def _loadData(self, data):
""" Load attribute values from Plex XML response. """
self._data = data
self.bottomLeft = data.attrib.get('bottomLeft')
self.bottomRight = data.attrib.get('bottomRight')
self.topLeft = data.attrib.get('topLeft')
self.topRight = data.attrib.get('topRight')


class BaseResource(PlexObject):
""" Base class for all Art, Poster, and Theme objects.
Expand Down
8 changes: 8 additions & 0 deletions plexapi/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ class Movie(
studio (str): Studio that created movie (Di Bonaventura Pictures; 21 Laps Entertainment).
tagline (str): Movie tag line (Back 2 Work; Who says men can't change?).
theme (str): URL to theme resource (/library/metadata/<ratingkey>/theme/<themeid>).
ultraBlurColors (:class:`~plexapi.media.UltraBlurColors`): Ultra blur color object.
useOriginalTitle (int): Setting that indicates if the original title is used for the movie
(-1 = Library default, 0 = No, 1 = Yes).
viewOffset (int): View offset in milliseconds.
Expand Down Expand Up @@ -420,6 +421,7 @@ def _loadData(self, data):
self.studio = data.attrib.get('studio')
self.tagline = data.attrib.get('tagline')
self.theme = data.attrib.get('theme')
self.ultraBlurColors = self.findItem(data, media.UltraBlurColors)
self.useOriginalTitle = utils.cast(int, data.attrib.get('useOriginalTitle', '-1'))
self.viewOffset = utils.cast(int, data.attrib.get('viewOffset', 0))
self.writers = self.findItems(data, media.Writer)
Expand Down Expand Up @@ -543,6 +545,7 @@ class Show(
(-1 = Account default, 0 = Manually selected, 1 = Shown with foreign audio, 2 = Always enabled).
tagline (str): Show tag line.
theme (str): URL to theme resource (/library/metadata/<ratingkey>/theme/<themeid>).
ultraBlurColors (:class:`~plexapi.media.UltraBlurColors`): Ultra blur color object.
useOriginalTitle (int): Setting that indicates if the original title is used for the show
(-1 = Library default, 0 = No, 1 = Yes).
viewedLeafCount (int): Number of items marked as played in the show view.
Expand Down Expand Up @@ -592,6 +595,7 @@ def _loadData(self, data):
self.subtitleMode = utils.cast(int, data.attrib.get('subtitleMode', '-1'))
self.tagline = data.attrib.get('tagline')
self.theme = data.attrib.get('theme')
self.ultraBlurColors = self.findItem(data, media.UltraBlurColors)
self.useOriginalTitle = utils.cast(int, data.attrib.get('useOriginalTitle', '-1'))
self.viewedLeafCount = utils.cast(int, data.attrib.get('viewedLeafCount'))
self.year = utils.cast(int, data.attrib.get('year'))
Expand Down Expand Up @@ -735,6 +739,7 @@ class Season(
subtitleLanguage (str): Setting that indicates the preferred subtitle language.
subtitleMode (int): Setting that indicates the auto-select subtitle mode.
(-1 = Series default, 0 = Manually selected, 1 = Shown with foreign audio, 2 = Always enabled).
ultraBlurColors (:class:`~plexapi.media.UltraBlurColors`): Ultra blur color object.
viewedLeafCount (int): Number of items marked as played in the season view.
year (int): Year the season was released.
"""
Expand Down Expand Up @@ -766,6 +771,7 @@ def _loadData(self, data):
self.ratings = self.findItems(data, media.Rating)
self.subtitleLanguage = data.attrib.get('subtitleLanguage', '')
self.subtitleMode = utils.cast(int, data.attrib.get('subtitleMode', '-1'))
self.ultraBlurColors = self.findItem(data, media.UltraBlurColors)
self.viewedLeafCount = utils.cast(int, data.attrib.get('viewedLeafCount'))
self.year = utils.cast(int, data.attrib.get('year'))

Expand Down Expand Up @@ -914,6 +920,7 @@ class Episode(
skipParent (bool): True if the show's seasons are set to hidden.
sourceURI (str): Remote server URI (server://<machineIdentifier>/com.plexapp.plugins.library)
(remote playlist item only).
ultraBlurColors (:class:`~plexapi.media.UltraBlurColors`): Ultra blur color object.
viewOffset (int): View offset in milliseconds.
writers (List<:class:`~plexapi.media.Writer`>): List of writers objects.
year (int): Year the episode was released.
Expand Down Expand Up @@ -958,6 +965,7 @@ def _loadData(self, data):
self.roles = self.findItems(data, media.Role)
self.skipParent = utils.cast(bool, data.attrib.get('skipParent', '0'))
self.sourceURI = data.attrib.get('source') # remote playlist item
self.ultraBlurColors = self.findItem(data, media.UltraBlurColors)
self.viewOffset = utils.cast(int, data.attrib.get('viewOffset', 0))
self.writers = self.findItems(data, media.Writer)
self.year = utils.cast(int, data.attrib.get('year'))
Expand Down
2 changes: 2 additions & 0 deletions tests/test_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def test_audio_Artist_attr(artist):
assert artist.title == "Broke For Free"
assert artist.titleSort == "Broke For Free"
assert artist.type == "artist"
assert artist.ultraBlurColors is None
assert utils.is_datetime(artist.updatedAt)
assert utils.is_int(artist.viewCount, gte=0)

Expand Down Expand Up @@ -185,6 +186,7 @@ def test_audio_Album_attrs(album):
assert album.title == "Layers"
assert album.titleSort == "Layers"
assert album.type == "album"
assert album.ultraBlurColors is not None
assert utils.is_datetime(album.updatedAt)
assert utils.is_int(album.viewCount, gte=0)
assert album.year in (2012,)
Expand Down
1 change: 1 addition & 0 deletions tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def test_Collection_attrs(collection):
assert collection.title == "Test Collection"
assert collection.titleSort == collection.title
assert collection.type == "collection"
assert utils.is_composite(collection.thumb, prefix="/library/collections") and collection.ultraBlurColors is None
assert utils.is_datetime(collection.updatedAt)
assert collection.listType == "video"
assert collection.metadataType == collection.subtype
Expand Down
12 changes: 12 additions & 0 deletions tests/test_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def test_video_Movie_attrs(movies):
assert movie.title == "Sita Sings the Blues"
assert movie.titleSort == "Sita Sings the Blues"
assert movie.type == "movie"
assert movie.ultraBlurColors is not None
assert movie.updatedAt > datetime(2017, 1, 1)
assert movie.useOriginalTitle == -1
assert movie.userRating is None
Expand Down Expand Up @@ -669,6 +670,14 @@ def test_video_Movie_batchEdits(movie):
movie.saveEdits()


def test_video_Movie_ultraBlurColors(movie):
ultraBlurColors = movie.ultraBlurColors
assert ultraBlurColors.bottomLeft
assert ultraBlurColors.bottomRight
assert ultraBlurColors.topLeft
assert ultraBlurColors.topRight


def test_video_Movie_mixins_edit_advanced_settings(movie):
test_mixins.edit_advanced_settings(movie)

Expand Down Expand Up @@ -817,6 +826,7 @@ def test_video_Show_attrs(show):
assert show.title == "Game of Thrones"
assert show.titleSort == "Game of Thrones"
assert show.type == "show"
assert show.ultraBlurColors is not None
assert show.useOriginalTitle == -1
assert show.userRating is None
assert utils.is_datetime(show.updatedAt)
Expand Down Expand Up @@ -1044,6 +1054,7 @@ def test_video_Season_attrs(show):
assert season.title == "Season 1"
assert season.titleSort == "Season 1"
assert season.type == "season"
assert season.ultraBlurColors is not None
assert utils.is_datetime(season.updatedAt)
assert utils.is_int(season.viewCount, gte=0)
assert utils.is_int(season.viewedLeafCount, gte=0)
Expand Down Expand Up @@ -1247,6 +1258,7 @@ def test_video_Episode_attrs(episode):
assert episode.title == "Winter Is Coming"
assert episode.titleSort == "Winter Is Coming"
assert episode.type == "episode"
assert episode.ultraBlurColors is not None
assert utils.is_datetime(episode.updatedAt)
assert episode.userRating is None
assert utils.is_int(episode.viewCount, gte=0)
Expand Down

0 comments on commit 1a0eb3c

Please sign in to comment.