albums = self.player.search_albums(artist)
# str conversion while Album type is not propagated
albums = [str(album) for album in albums]
- if albums:
- self.log.debug('Albums candidate: %s', ' / '.join(albums))
- else: continue
+ if not albums:
+ continue
+ self.log.debug('Albums candidate: %s', ' / '.join(albums))
# albums yet in history for this artist
albums = set(albums)
albums_yet_in_hist = albums & self._get_album_history(artist=artist)
"""Get some tracks for track queue mode
"""
artists = self.get_local_similar_artists()
- nbtracks_target = self.plugin_conf.getint('track_to_add') # pylint: disable=no-member
+ nbtracks_target = self.plugin_conf.getint('track_to_add') # pylint: disable=no-member
for artist in artists:
self.log.debug('Trying to find titles to add for "%r"', artist)
- found = self.player.find_track(artist)
+ found = self.player.find_tracks(artist)
random.shuffle(found)
if not found:
- self.log.debug('Found nothing to queue for {0}'.format(artist))
+ self.log.debug('Found nothing to queue for %s', artist)
continue
# find tracks not in history for artist
self.filter_track(found)
self.log.debug('Found no tracks to queue!')
return None
for track in self.to_add:
- self.log.info('{1} candidates: {0!s}'.format(track, self.ws.name))
+ self.log.info('%s candidates: %s', track, self.ws.name)
def _album(self):
"""Get albums for album queue mode
# ######### / Properties ###################
# #### find_tracks ####
- def find_album(self, artist, album_name):
- self.log.warning('update call to find_album→find_tracks(<Album object>)')
- return self.find_tracks(Album(name=album_name, artist=artist))
-
- def find_track(self, *args, **kwargs):
- self.log.warning('update call to find_track→find_tracks')
- return self.find_tracks(*args, **kwargs)
-
def find_tracks(self, what):
"""Find tracks for a specific artist or album
>>> player.find_tracks(Artist('Nirvana'))
>>> ['The Beatles', 'Beatles', 'the beatles']
Returns an Artist object
- TODO: Re-use find method here!!!
"""
found = False
- if artist.mbid:
+ if self.use_mbid and artist.mbid:
# look for exact search w/ musicbrainz_artistid
- exact_m = self.list('artist', 'musicbrainz_artistid', artist.mbid)
+ exact_m = self.list('artist', f"(MUSICBRAINZ_ARTISTID == '{artist.mbid}')")
if exact_m:
_ = [artist.add_alias(name) for name in exact_m]
found = True
if album and album not in albums:
albums.append(Album(name=album, **kwalbart))
for album in self.list('album', 'artist', name):
- album_trks = [trk for trk in self.find('album', album)]
+ album_trks = self.find_tracks(Album(name=album, artist=Artist(name=name)))
if 'Various Artists' in [tr.albumartist for tr in album_trks]:
self.log.debug('Discarding %s ("Various Artists" set)', album)
continue