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)
|
self._original_data = client.gp.get_artist_info(self._id)
|
||||||
albums = [Album(self, album) for album in self._original_data['albums']]
|
albums = [Album(self, album) for album in self._original_data['albums']]
|
||||||
albums.sort()
|
albums.sort()
|
||||||
|
albums.insert(0, AllSongs(self, albums.copy()))
|
||||||
albums.insert(0, TopSongs(self, Track.from_data(self._original_data['topTracks'],
|
albums.insert(0, TopSongs(self, Track.from_data(self._original_data['topTracks'],
|
||||||
Source.album, many=True)))
|
Source.album, many=True)))
|
||||||
albums.insert(1, AllSongs(self, albums.copy()))
|
|
||||||
self._albums = albums
|
self._albums = albums
|
||||||
|
|
||||||
return self._albums #: Warning: passes by reference for efficiency
|
return self._albums #: Warning: passes by reference for efficiency
|
||||||
|
|
|
@ -114,7 +114,7 @@ class _GP(object):
|
||||||
"""
|
"""
|
||||||
Get the artist info
|
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
|
@synchronized
|
||||||
def get_album_tracks(self, album_id):
|
def get_album_tracks(self, album_id):
|
||||||
|
@ -134,10 +134,11 @@ class _GP(object):
|
||||||
Returns:
|
Returns:
|
||||||
The artist class
|
The artist class
|
||||||
"""
|
"""
|
||||||
if artist_id not in self.cached_artists:
|
lname = name.lower()
|
||||||
self.cached_artists[artist_id] = Artist(artist_id, name)
|
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
|
@synchronized
|
||||||
def use_authtoken(self, authtoken, device_id):
|
def use_authtoken(self, authtoken, device_id):
|
||||||
|
|
|
@ -56,11 +56,19 @@ class Track(object):
|
||||||
key=lambda x: x['aspectRatio']
|
key=lambda x: x['aspectRatio']
|
||||||
)), None)
|
)), None)
|
||||||
self.title = data['title']
|
self.title = data['title']
|
||||||
if 'artistId' in data:
|
self.artist = data['artist']
|
||||||
self.artist = client.gp.add_artist(data['artistId'][0], data['artist'])
|
|
||||||
else:
|
if 'artistId' in data and data['artistId'] != "" and source == Source.library:
|
||||||
self.artist = data['artist']
|
if 'albumArtist' not in data or data['albumArtist'] == "":
|
||||||
# TODO: How to deal with uploaded music
|
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'])
|
# client.gp.add_artist(UUID().hex, data['artist'])
|
||||||
|
|
||||||
#self.artist = client.gp.add_artist(data['artistId'][0])
|
#self.artist = client.gp.add_artist(data['artistId'][0])
|
||||||
|
|
|
@ -172,7 +172,7 @@ class AbstractPlayer:
|
||||||
data = dict(
|
data = dict(
|
||||||
loading=self._loading,
|
loading=self._loading,
|
||||||
playing=self._playing,
|
playing=self._playing,
|
||||||
artist=track.artist.name,
|
artist=track.artist,
|
||||||
title=track.title,
|
title=track.title,
|
||||||
progress=self.play_progress_seconds,
|
progress=self.play_progress_seconds,
|
||||||
length=self.length_seconds,
|
length=self.length_seconds,
|
||||||
|
|
Loading…
Add table
Reference in a new issue