Add support for artist popular tracks (#1453)

* Add artist popular tracks

* Test artist popular tracks
This commit is contained in:
JonnyWong16 2024-08-17 14:26:11 -07:00 committed by GitHub
parent e23cd8d158
commit 075e7d7e12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 1 deletions

View file

@ -281,6 +281,21 @@ class Artist(
filepaths += track.download(_savepath, keep_original_name, **kwargs)
return filepaths
def popularTracks(self):
""" Returns a list of :class:`~plexapi.audio.Track` popular tracks by the artist. """
filters = {
'album.subformat!': 'Compilation,Live',
'artist.id': self.ratingKey,
'group': 'title',
'ratingCount>>': 0,
}
return self.section().search(
libtype='track',
filters=filters,
sort='ratingCount:desc',
limit=100
)
def station(self):
""" Returns a :class:`~plexapi.playlist.Playlist` artist radio station or `None`. """
key = f'{self.key}?includeStations=1'

View file

@ -2823,7 +2823,8 @@ class FilteringType(PlexObject):
additionalFields.extend([
('duration', 'integer', 'Duration'),
('viewOffset', 'integer', 'View Offset'),
('label', 'tag', 'Label')
('label', 'tag', 'Label'),
('ratingCount', 'integer', 'Rating Count'),
])
elif self.type == 'collection':
additionalFields.extend([

View file

@ -88,6 +88,11 @@ def test_audio_Artist_hubs(artist):
assert isinstance(hubs, list)
def test_audio_Artist_popularTracks(artist):
tracks = artist.popularTracks()
assert len(tracks)
def test_audio_Artist_mixins_edit_advanced_settings(artist):
test_mixins.edit_advanced_settings(artist)