X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Fmpdclient.py;h=0866e4c59c46a60994c94d51378f139036bc08a6;hb=cd79c4c0522230a3cdfc6bb53e78ab2bdd81e9ee;hp=6b461bacc28e86476bf5c0471ba419c3d2c2562f;hpb=31cb581a72f067990a5dc3917542d15505f86990;p=mpd-sima.git diff --git a/sima/mpdclient.py b/sima/mpdclient.py index 6b461ba..0866e4c 100644 --- a/sima/mpdclient.py +++ b/sima/mpdclient.py @@ -331,15 +331,16 @@ class MPD(MPDClient): raise PlayerError('Album object have no artist attribute') albums = [] if self.use_mbid and album.mbid: - filt = f'(MUSICBRAINZ_ALBUMID == {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_ALBUMARTISTID == '{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.name_sz}'))" - albums = self.find(filt) + for artist in album.artist.names_sz: + filt = f"((albumartist == '{artist}') AND (album == '{album.name_sz}'))" + albums.extend(self.find(filt)) return albums # #### / find_tracks ## @@ -360,9 +361,16 @@ class MPD(MPDClient): found = False if self.use_mbid and artist.mbid: # look for exact search w/ musicbrainz_artistid - found = bool(self.list('artist', f"(MUSICBRAINZ_ARTISTID == '{artist.mbid}')")) - if found: + library = self.list('artist', f"(MUSICBRAINZ_ARTISTID == '{artist.mbid}')") + if library: + found = True self.log.trace('Found mbid "%r" in library', artist) + # library could fetch several artist name for a single MUSICBRAINZ_ARTISTID + if len(library) > 1: + self.log.warning('I got "%s" searching for %r', library, artist) + elif len(library) == 1 and library[0] != artist.name: + self.log.debug('Update artist name %s->%s', artist, library[0]) + artist = Artist(name=library[0], mbid=artist.mbid) # Fetches remaining artists for potential match artists = self._cache['nombid_artists'] else: # not using MusicBrainzIDs @@ -386,6 +394,7 @@ class MPD(MPDClient): self.log.trace('no fuzzy matching for %r', artist) if found: return artist + return None # Now perform fuzzy search for fuzz in match: if fuzz in artist.names: # Already found in lower cased comparison