]> kaliko git repositories - mpd-sima.git/blobdiff - sima/mpdclient.py
Fixed MPD client (issue when no albumartist is set)
[mpd-sima.git] / sima / mpdclient.py
index 0784fa6935c28d5d9490f77c6e62ea8bb2476990..9b8df6a18d42e474949d7dc268f55d1fbe698a89 100644 (file)
@@ -312,23 +312,23 @@ class MPD(MPDClient):
         tracks = set()
         if artist.mbid:
             tracks |= set(self.find('musicbrainz_artistid', artist.mbid))
-        for name in artist.names:
+        for name in artist.names_sz:
             tracks |= set(self.find('artist', name))
         return list(tracks)
 
     def _find_alb(self, album):
         if not hasattr(album, 'artist'):
-            PlayerError('Album object have no artist attribute')
+            raise PlayerError('Album object have no artist attribute')
         albums = []
         if self.use_mbid and album.mbid:
             filt = f'(MUSICBRAINZ_ALBUMID == {album.mbid})'
             albums = self.find(filt)
         # Now look for album with no MusicBrainzIdentifier
         if not albums and album.artist.mbid and self.use_mbid:  # Use album artist MBID if possible
-            filt = f"((MUSICBRAINZ_ARTISTID == '{album.artist.mbid}') AND (album == '{album!s}'))"
+            filt = f"((MUSICBRAINZ_ARTISTID == '{album.artist.mbid}') AND (album == '{album.name_sz}'))"
             albums = self.find(filt)
         if not albums:  # Falls back to (album)?artist/album name
-            filt = f"((albumartist == '{album.artist!s}') AND (album == '{album!s}'))"
+            filt = f"((albumartist == '{album.artist!s}') AND (album == '{album.name_sz}'))"
             albums = self.find(filt)
         return albums
 # #### / find_tracks ##
@@ -429,7 +429,7 @@ class MPD(MPDClient):
         TODO: Use MusicBrainzID here cf. #30 @gitlab
         """
         albums = []
-        for name in artist.names:
+        for name in artist.names_sz:
             if artist.aliases:
                 self.log.debug('Searching album for aliase: "%s"', name)
             kwalbart = {'albumartist': name, 'artist': name}
@@ -442,7 +442,7 @@ class MPD(MPDClient):
                 if 'Various Artists' in [tr.albumartist for tr in album_trks]:
                     self.log.debug('Discarding %s ("Various Artists" set)', album)
                     continue
-                if name not in album_artists:
+                if album_artists and name not in album_artists:
                     self.log.debug('Discarding "%s", "%s" not set as albumartist', album, name)
                     continue
                 arts = {trk.artist for trk in album_trks}