Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add genres attribute to Track #1318

Merged
merged 4 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plexapi/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ class Track(
chapterSource (str): Unknown
collections (List<:class:`~plexapi.media.Collection`>): List of collection objects.
duration (int): Length of the track in milliseconds.
genres (List<:class:`~plexapi.media.Genre`>): List of genre objects.
grandparentArt (str): URL to album artist artwork (/library/metadata/<grandparentRatingKey>/art/<artid>).
grandparentGuid (str): Plex GUID for the album artist (plex://artist/5d07bcb0403c64029053ac4c).
grandparentKey (str): API URL of the album artist (/library/metadata/<grandparentRatingKey>).
Expand Down Expand Up @@ -463,6 +464,7 @@ def _loadData(self, data):
self.chapterSource = data.attrib.get('chapterSource')
self.collections = self.findItems(data, media.Collection)
self.duration = utils.cast(int, data.attrib.get('duration'))
self.genres = self.findItems(data, media.Genre)
self.grandparentArt = data.attrib.get('grandparentArt')
self.grandparentGuid = data.attrib.get('grandparentGuid')
self.grandparentKey = data.attrib.get('grandparentKey')
Expand Down
2 changes: 1 addition & 1 deletion plexapi/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ class AlbumEditMixins(
class TrackEditMixins(
ArtLockMixin, PosterLockMixin, ThemeLockMixin,
AddedAtMixin, TitleMixin, TrackArtistMixin, TrackNumberMixin, TrackDiscNumberMixin, UserRatingMixin,
CollectionMixin, LabelMixin, MoodMixin
CollectionMixin, GenreMixin, LabelMixin, MoodMixin
):
pass

Expand Down
2 changes: 2 additions & 0 deletions tests/test_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ def test_audio_Track_attrs(album):
assert utils.is_art(track.art)
assert track.chapterSource is None
assert utils.is_int(track.duration)
assert track.genres == []
if track.grandparentArt:
assert utils.is_art(track.grandparentArt)
assert utils.is_metadata(track.grandparentKey)
Expand Down Expand Up @@ -418,6 +419,7 @@ def test_audio_Track_mixins_fields(track):

def test_audio_Track_mixins_tags(track):
test_mixins.edit_collection(track)
test_mixins.edit_genre(track)
test_mixins.edit_label(track)
test_mixins.edit_mood(track)

Expand Down