mirror of
https://github.com/vale981/clay
synced 2025-03-06 01:51:38 -05:00
Only show artists with songs in the library
This commit is contained in:
parent
dbd628cddd
commit
3514ba211d
4 changed files with 21 additions and 11 deletions
|
@ -46,9 +46,10 @@ class Artist(object):
|
|||
self._original_data = client.gp.get_artist_info(self._id)
|
||||
albums = [Album(self, album) for album in self._original_data['albums']]
|
||||
albums.sort()
|
||||
albums.insert(0, AllSongs(self, albums.copy()))
|
||||
albums.insert(0, TopSongs(self, Track.from_data(self._original_data['topTracks'],
|
||||
Source.album, many=True)))
|
||||
albums.insert(1, AllSongs(self, albums.copy()))
|
||||
|
||||
self._albums = albums
|
||||
|
||||
return self._albums #: Warning: passes by reference for efficiency
|
||||
|
|
|
@ -114,7 +114,7 @@ class _GP(object):
|
|||
"""
|
||||
Get the artist info
|
||||
"""
|
||||
return self.mobile_client.get_artist_info(artist_id)
|
||||
return self.mobile_client.get_artist_info(artist_id, max_rel_artist=0, max_top_tracks=15)
|
||||
|
||||
@synchronized
|
||||
def get_album_tracks(self, album_id):
|
||||
|
@ -134,10 +134,11 @@ class _GP(object):
|
|||
Returns:
|
||||
The artist class
|
||||
"""
|
||||
if artist_id not in self.cached_artists:
|
||||
self.cached_artists[artist_id] = Artist(artist_id, name)
|
||||
lname = name.lower()
|
||||
if lname not in self.cached_artists:
|
||||
self.cached_artists[lname] = Artist(artist_id, name)
|
||||
|
||||
return self.cached_artists[artist_id]
|
||||
return self.cached_artists[lname]
|
||||
|
||||
@synchronized
|
||||
def use_authtoken(self, authtoken, device_id):
|
||||
|
|
|
@ -56,10 +56,18 @@ class Track(object):
|
|||
key=lambda x: x['aspectRatio']
|
||||
)), None)
|
||||
self.title = data['title']
|
||||
if 'artistId' in data:
|
||||
self.artist = client.gp.add_artist(data['artistId'][0], data['artist'])
|
||||
else:
|
||||
self.artist = data['artist']
|
||||
|
||||
if 'artistId' in data and data['artistId'] != "" and source == Source.library:
|
||||
if 'albumArtist' not in data or data['albumArtist'] == "":
|
||||
self.album_artist = client.gp.add_artist(data['artistId'][0], data['artist'])
|
||||
|
||||
self.album_artist = client.gp.add_artist(data['artistId'][0], data['albumArtist'])
|
||||
#elif source == Source.library:
|
||||
# import sys
|
||||
# print(data['artist'], file=sys.stderr)
|
||||
# self.album_artist = client.gp.add_artist(data.get('albumArtist', self.artist))
|
||||
|
||||
# TODO: How to deal with uploaded music
|
||||
# client.gp.add_artist(UUID().hex, data['artist'])
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ class AbstractPlayer:
|
|||
data = dict(
|
||||
loading=self._loading,
|
||||
playing=self._playing,
|
||||
artist=track.artist.name,
|
||||
artist=track.artist,
|
||||
title=track.title,
|
||||
progress=self.play_progress_seconds,
|
||||
length=self.length_seconds,
|
||||
|
|
Loading…
Add table
Reference in a new issue