# ######### / Properties ###################
# #### find_tracks ####
- def find_album(self, artist, album_name):
- self.log.warning('update call to find_album→find_tracks(<Album object>)')
- return self.find_tracks(Album(name=album_name, artist=artist))
-
- def find_track(self, *args, **kwargs):
- self.log.warning('update call to find_track→find_tracks')
- return self.find_tracks(*args, **kwargs)
-
def find_tracks(self, what):
"""Find tracks for a specific artist or album
>>> player.find_tracks(Artist('Nirvana'))
def _find_art(self, artist):
tracks = set()
- if artist.mbid:
+ if self.use_mbid and artist.mbid:
tracks |= set(self.find('musicbrainz_artistid', artist.mbid))
for name in artist.names:
tracks |= set(self.find('artist', name))
return list(tracks)
def _find_alb(self, album):
- albums = set()
if album.mbid and self.use_mbid:
filt = f'(MUSICBRAINZ_ALBUMID == {album.mbid})'
- albums |= set(self.find(filt))
+ return self.find(filt)
# Now look for album with no MusicBrainzIdentifier
if album.artist.mbid and self.use_mbid: # Use album artist MBID if possible
filt = f"((MUSICBRAINZ_ALBUMARTISTID == '{album.artist.mbid}') AND (album == '{album!s}'))"
- albums |= set(self.find(filt))
- if not albums: # Falls back to albumartist/album name
- filt = f"((albumartist == '{album.artist!s}') AND (album == '{album!s}'))"
- albums |= set(self.find(filt))
- if not albums: # Falls back to artist/album name
+ return self.find(filt)
+ tracks = []
+ # Falls back to albumartist/album name
+ filt = f"((albumartist == '{album.artist!s}') AND (album == '{album!s}'))"
+ tracks = self.find(filt)
+ # Falls back to artist/album name
+ if not tracks:
filt = f"((artist == '{album.artist!s}') AND (album == '{album!s}'))"
- albums |= set(self.find(filt))
- return list(albums)
+ tracks = self.find(filt)
+ return tracks
# #### / find_tracks ##
# #### Search Methods #####
>>> ['The Beatles', 'Beatles', 'the beatles']
Returns an Artist object
- TODO: Re-use find method here!!!
"""
found = False
- if artist.mbid:
+ if self.use_mbid and artist.mbid:
# look for exact search w/ musicbrainz_artistid
- exact_m = self.list('artist', 'musicbrainz_artistid', artist.mbid)
+ exact_m = self.list('artist', f"(MUSICBRAINZ_ARTISTID == '{artist.mbid}')")
if exact_m:
_ = [artist.add_alias(name) for name in exact_m]
found = True
if album and album not in albums:
albums.append(Album(name=album, **kwalbart))
for album in self.list('album', 'artist', name):
- album_trks = [trk for trk in self.find('album', album)]
+ album_trks = self.find_tracks(Album(name=album, artist=Artist(name=name)))
if 'Various Artists' in [tr.albumartist for tr in album_trks]:
self.log.debug('Discarding %s ("Various Artists" set)', album)
continue