Skip to content

Commit

Permalink
Adds Movie and Artist advanced setting attributes (#680)
Browse files Browse the repository at this point in the history
* Add advanced setting attributes to movie

* Add advanced setting attributes to artist

* Update tests for movie advanced setting attributes

* Update tests for artist advanced setting attributes

* Fix artist albumSort attribute
  • Loading branch information
JonnyWong16 authored Mar 11, 2021
1 parent 7bdc9ed commit c15133d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plexapi/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class Artist(Audio, ArtMixin, PosterMixin, SplitMergeMixin, UnmatchMatchMixin,
Attributes:
TAG (str): 'Directory'
TYPE (str): 'artist'
albumSort (int): Setting that indicates how albums are sorted for the artist
(-1 = Library default, 0 = Newest first, 1 = Oldest first, 2 = By name).
collections (List<:class:`~plexapi.media.Collection`>): List of collection objects.
countries (List<:class:`~plexapi.media.Country`>): List country objects.
genres (List<:class:`~plexapi.media.Genre`>): List of genre objects.
Expand All @@ -135,6 +137,7 @@ class Artist(Audio, ArtMixin, PosterMixin, SplitMergeMixin, UnmatchMatchMixin,
def _loadData(self, data):
""" Load attribute values from Plex XML response. """
Audio._loadData(self, data)
self.albumSort = utils.cast(int, data.attrib.get('albumSort', '-1'))
self.collections = self.findItems(data, media.Collection)
self.countries = self.findItems(data, media.Country)
self.genres = self.findItems(data, media.Genre)
Expand Down
6 changes: 6 additions & 0 deletions plexapi/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ class Movie(Video, Playable, ArtMixin, PosterMixin, SplitMergeMixin, UnmatchMatc
genres (List<:class:`~plexapi.media.Genre`>): List of genre objects.
guids (List<:class:`~plexapi.media.Guid`>): List of guid objects.
labels (List<:class:`~plexapi.media.Label`>): List of label objects.
languageOverride (str): Setting that indicates if a languge is used to override metadata
(eg. en-CA, None = Library default).
media (List<:class:`~plexapi.media.Media`>): List of media objects.
originallyAvailableAt (datetime): Datetime the movie was released.
originalTitle (str): Original title, often the foreign title (転々; 엽기적인 그녀).
Expand All @@ -278,6 +280,8 @@ class Movie(Video, Playable, ArtMixin, PosterMixin, SplitMergeMixin, UnmatchMatc
similar (List<:class:`~plexapi.media.Similar`>): List of Similar objects.
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?).
useOriginalTitle (int): Setting that indicates if the original title is used for the movie
(-1 = Library default, 0 = No, 1 = Yes).
userRating (float): User rating (2.0; 8.0).
viewOffset (int): View offset in milliseconds.
writers (List<:class:`~plexapi.media.Writer`>): List of writers objects.
Expand All @@ -303,6 +307,7 @@ def _loadData(self, data):
self.genres = self.findItems(data, media.Genre)
self.guids = self.findItems(data, media.Guid)
self.labels = self.findItems(data, media.Label)
self.languageOverride = data.attrib.get('languageOverride')
self.media = self.findItems(data, media.Media)
self.originallyAvailableAt = utils.toDatetime(data.attrib.get('originallyAvailableAt'), '%Y-%m-%d')
self.originalTitle = data.attrib.get('originalTitle')
Expand All @@ -314,6 +319,7 @@ def _loadData(self, data):
self.similar = self.findItems(data, media.Similar)
self.studio = data.attrib.get('studio')
self.tagline = data.attrib.get('tagline')
self.useOriginalTitle = utils.cast(int, data.attrib.get('useOriginalTitle', '-1'))
self.userRating = utils.cast(float, data.attrib.get('userRating'))
self.viewOffset = utils.cast(int, data.attrib.get('viewOffset', 0))
self.writers = self.findItems(data, media.Writer)
Expand Down
1 change: 1 addition & 0 deletions tests/test_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
def test_audio_Artist_attr(artist):
artist.reload()
assert utils.is_datetime(artist.addedAt)
assert artist.albumSort == -1
if artist.art:
assert utils.is_art(artist.art)
if artist.countries:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def test_video_Movie_attrs(movies):
assert movie.guid == "plex://movie/5d776846880197001ec967c6"
assert utils.is_metadata(movie._initpath)
assert utils.is_metadata(movie.key)
assert movie.languageOverride is None
assert utils.is_datetime(movie.lastViewedAt)
assert int(movie.librarySectionID) >= 1
assert movie.listType == "video"
Expand All @@ -206,6 +207,7 @@ def test_video_Movie_attrs(movies):
assert not movie.transcodeSessions
assert movie.type == "movie"
assert movie.updatedAt > datetime(2017, 1, 1)
assert movie.useOriginalTitle == -1
assert movie.userRating is None
assert movie.viewCount == 0
assert utils.is_int(movie.viewOffset, gte=0)
Expand Down

0 comments on commit c15133d

Please sign in to comment.