From: kaliko Date: Sun, 10 May 2020 13:58:05 +0000 (+0200) Subject: Some more cleanup, logs and player calls X-Git-Tag: 0.16.0.dev0~22 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=31b3f50c99aa088bf21a3ac2ad6e8a974dfb4105;p=mpd-sima.git Some more cleanup, logs and player calls --- diff --git a/sima/lib/webserv.py b/sima/lib/webserv.py index 38339f2..2a9b855 100644 --- a/sima/lib/webserv.py +++ b/sima/lib/webserv.py @@ -317,9 +317,9 @@ class WebService(Plugin): 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) @@ -387,13 +387,13 @@ class WebService(Plugin): """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) @@ -403,7 +403,7 @@ class WebService(Plugin): 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 diff --git a/sima/mpdclient.py b/sima/mpdclient.py index 82c6dbb..13aa0b0 100644 --- a/sima/mpdclient.py +++ b/sima/mpdclient.py @@ -289,14 +289,6 @@ class MPD(MPDClient): # ######### / Properties ################### # #### find_tracks #### - def find_album(self, artist, album_name): - self.log.warning('update call to find_album→find_tracks()') - 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')) @@ -351,12 +343,11 @@ class MPD(MPDClient): >>> ['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 @@ -446,7 +437,7 @@ class MPD(MPDClient): 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