class PlayerError(Exception):
- """Fatal error in poller."""
+ """Fatal error in the player."""
# Some decorators
"""
needed_cmds = ['status', 'stats', 'add', 'find',
'search', 'currentsong', 'ping']
- needed_mbid_tags = {'Artist', 'Album', 'AlbumArtist',
- 'Title', 'Track', 'Genre',
- 'MUSICBRAINZ_ARTISTID', 'MUSICBRAINZ_ALBUMID',
+ needed_tags = {'Artist', 'Album', 'AlbumArtist', 'Title', 'Track'}
+ needed_mbid_tags = {'MUSICBRAINZ_ARTISTID', 'MUSICBRAINZ_ALBUMID',
'MUSICBRAINZ_ALBUMARTISTID', 'MUSICBRAINZ_TRACKID'}
+ MPD_supported_tags = {'Artist', 'ArtistSort', 'Album', 'AlbumSort', 'AlbumArtist',
+ 'AlbumArtistSort', 'Title', 'Track', 'Name', 'Genre',
+ 'Date', 'OriginalDate', 'Composer', 'Performer',
+ 'Conductor', 'Work', 'Grouping', 'Disc', 'Label',
+ 'MUSICBRAINZ_ARTISTID', 'MUSICBRAINZ_ALBUMID',
+ 'MUSICBRAINZ_ALBUMARTISTID', 'MUSICBRAINZ_TRACKID',
+ 'MUSICBRAINZ_RELEASETRACKID', 'MUSICBRAINZ_WORKID'}
database = None
def __init__(self, daemon):
raise PlayerError('Could connect to "%s", '
'but command "%s" not available' %
(host, cmd))
- # Controls use of MusicBrainzIdentifier
self.tagtypes('clear')
+ for tag in MPD.needed_tags:
+ self.tagtypes('enable', tag)
+ tt = set(map(str.lower, self.tagtypes()))
+ needed_tags = set(map(str.lower, MPD.needed_tags))
+ if len(needed_tags & tt) != len(MPD.needed_tags):
+ self.log.warning('MPD exposes: %s', tt)
+ self.log.warning('Tags needed: %s', needed_tags)
+ raise PlayerError('Missing mandatory metadata!')
for tag in MPD.needed_mbid_tags:
self.tagtypes('enable', tag)
+ # Controls use of MusicBrainzIdentifier
if self.daemon.config.get('sima', 'musicbrainzid'):
tt = set(self.tagtypes())
if len(MPD.needed_mbid_tags & tt) != len(MPD.needed_mbid_tags):
if len(library) > 1:
self.log.debug('I got "%s" searching for %r', library, artist)
elif len(library) == 1 and library[0] != artist.name:
+ new_alias = artist.name
self.log.info('Update artist name %s->%s', artist, library[0])
+ self.log.debug('Also add alias for %s: %s', artist, new_alias)
artist = Artist(name=library[0], mbid=artist.mbid)
+ artist.add_alias(new_alias)
# Fetches remaining artists for potential match
artists = self._cache['nombid_artists']
else: # not using MusicBrainzIDs
looking for albums for Artist_B returns wrongly this album.
"""
# First, look for all potential albums
- self.log.debug('Searching album for "%s"', artist)
+ self.log.debug('Searching album for "%r"', artist)
if artist.aliases:
self.log.debug('Searching album for %s aliases: "%s"',
artist, artist.aliases)