- tracks = list()
- if isinstance(artist, Artist):
- for name in artist.names:
- tracks.extend(self._find_track(name, title=title))
+ tracks = set()
+ for name in artist.names:
+ if title:
+ tracks |= set(self.find('artist', name, 'title', title))
+ else:
+ tracks |= set(self.find('artist', name))
+ if artist.mbid:
+ if title:
+ tracks |= set(self.find('musicbrainz_artistid', artist.mbid))
+ else:
+ tracks |= set(self.find('musicbrainz_artistid', artist.mbid,
+ 'title', title))
+ return list(tracks)
+
+ @bl_artist
+ def search_artist(self, artist):
+ """
+ Search artists based on a fuzzy search in the media library
+ >>> art = Artist(name='the beatles', mbid=<UUID4>) # mbid optional
+ >>> bea = player.search_artist(art)
+ >>> print(bea.names)
+ >>> ['The Beatles', 'Beatles', 'the beatles']
+
+ Returns an Artist object
+ """
+ found = False
+ if artist.mbid:
+ # look for exact search w/ musicbrainz_artistid
+ exact_m = self._execute('list', ['artist', 'musicbrainz_artistid', artist.mbid])
+ if exact_m:
+ [artist.add_alias(name) for name in exact_m]
+ found = True
+ else:
+ artist = Artist(name=artist.name)
+ # then complete with fuzzy search on artist with no musicbrainz_artistid
+ if artist.mbid:
+ # we already performed a lookup on artists with mbid set
+ # search through remaining artists
+ artists = self._cache.get('nombid_artists', [])