+ @blacklist(album=True)
+ def search_albums(self, artist):
+ """
+ Fetch all albums for "AlbumArtist" == artist
+ Filter albums returned for "artist" == artist since MPD returns any
+ album containing at least a single track for artist
+ """
+ albums = []
+ for name in artist.names:
+ if len(artist.names) > 1:
+ self.log.debug('Searching album for aliase: "%s"', name)
+ kwalbart = {'albumartist':name, 'artist':name}
+ for album in self.list('album', 'albumartist', artist):
+ if album and album not in albums:
+ albums.append(Album(name=album, **kwalbart))
+ for album in self.list('album', 'artist', artist):
+ album_trks = [trk for trk in self.find('album', album)]
+ if 'Various Artists' in [tr.albumartist for tr in album_trks]:
+ self.log.debug('Discarding %s ("Various Artists" set)', album)
+ continue
+ arts = set([trk.artist for trk in album_trks])
+ if len(set(arts)) < 2: # TODO: better heuristic, use a ratio instead
+ if album not in albums:
+ albums.append(Album(name=album, **kwalbart))
+ elif album and album not in albums:
+ self.log.debug('"{0}" probably not an album of "{1}"'.format(
+ album, artist) + '({0})'.format('/'.join(arts)))
+ return albums
+