- #return getattr(self, 'find')('artist', artist, 'title', title)
- if title:
- return self.find('artist', artist, 'title', title)
- return self.find('artist', artist)
-
- @blacklist(artist=True)
- def fuzzy_find_artist(self, art):
- """
- Controls presence of artist in music library.
- Crosschecking artist names with SimaStr objects / difflib / levenshtein
-
- TODO: proceed crosschecking even when an artist matched !!!
- Not because we found "The Doors" as "The Doors" that there is no
- remaining entries as "Doors" :/
- not straight forward, need probably heavy refactoring.
- """
- matching_artists = list()
- artist = SimaStr(art)
-
- # Check against the actual string in artist list
- if artist.orig in self.artists:
- self.log.debug('found exact match for "%s"' % artist)
- return [artist]
- # Then proceed with fuzzy matching if got nothing
- match = get_close_matches(artist.orig, self.artists, 50, 0.73)
+ 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)
+
+ def fuzzy_find_track(self, artist, title):
+ # Retrieve all tracks from artist
+ all_tracks = self.find_track(artist, title)
+ # Get all titles (filter missing titles set to 'None')
+ all_artist_titles = frozenset([tr.title for tr in all_tracks
+ if tr.title is not None])
+ match = get_close_matches(title, all_artist_titles, 50, 0.78)