From: kaliko Date: Thu, 14 May 2020 16:16:28 +0000 (+0200) Subject: MPD client: Use tagtypes to control and set tags X-Git-Tag: 0.16.0.dev0~10 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=54849baefbe39c4c0a09bd8ad27bde7743dac5ef;p=mpd-sima.git MPD client: Use tagtypes to control and set tags --- diff --git a/sima/launch.py b/sima/launch.py index 1ae3c19..c472567 100644 --- a/sima/launch.py +++ b/sima/launch.py @@ -34,7 +34,6 @@ from os.path import isfile # local import from . import core, info from .lib.logger import set_logger -from .lib.meta import Meta from .lib.simadb import SimaDB from .utils.config import ConfMan from .utils.startopt import StartOpt @@ -121,11 +120,7 @@ def start(sopt, restart=False): # Loading contrib plugins load_plugins(sima, 'contrib') - logger.info('plugins loaded, prioriy: {}'.format(' > '.join(map(str, sima.plugins)))) - # Set use of MusicBrainzIdentifier - if not config.getboolean('sima', 'musicbrainzid'): - logger.info('Disabling MusicBrainzIdentifier') - Meta.use_mbid = False + logger.info('plugins loaded, prioriy: %s', ' > '.join(map(str, sima.plugins))) # Run as a daemon if config.getboolean('daemon', 'daemon'): diff --git a/sima/mpdclient.py b/sima/mpdclient.py index e8f6972..97be9da 100644 --- a/sima/mpdclient.py +++ b/sima/mpdclient.py @@ -26,7 +26,7 @@ from musicpd import MPDClient, MPDError # local import -from .lib.meta import Artist, Album +from .lib.meta import Meta, Artist, Album from .lib.track import Track from .lib.simastr import SimaStr from .utils.leven import levenshtein_ratio @@ -115,6 +115,10 @@ class MPD(MPDClient): """ needed_cmds = ['status', 'stats', 'add', 'find', 'search', 'currentsong', 'ping'] + needed_mbid_tags = {'Artist', 'Album', 'AlbumArtist', + 'Title', 'Track', 'Genre', + 'MUSICBRAINZ_ARTISTID', 'MUSICBRAINZ_ALBUMID', + 'MUSICBRAINZ_ALBUMARTISTID', 'MUSICBRAINZ_TRACKID'} database = None def __init__(self, daemon): @@ -176,20 +180,24 @@ class MPD(MPDClient): 'but command "%s" not available' % (host, cmd)) # Controls use of MusicBrainzIdentifier - # TODO: Use config instead of Artist object attibute? - if self.use_mbid: - tt = self.tagtypes() - if 'MUSICBRAINZ_ARTISTID' not in tt: - self.log.warning('Use of MusicBrainzIdentifier is set but MPD is ' - 'not providing related metadata') + self.tagtypes('clear') + for tag in MPD.needed_mbid_tags: + self.tagtypes('enable', tag) + if self.daemon.config.get('sima', 'musicbrainzid'): + tt = set(self.tagtypes()) + if len(MPD.needed_mbid_tags & tt) != len(MPD.needed_mbid_tags): + self.log.warning('Use of MusicBrainzIdentifier is set but MPD ' + 'is not providing related metadata') self.log.info(tt) self.log.warning('Disabling MusicBrainzIdentifier') - self.use_mbid = False + self.use_mbid = Meta.use_mbid = False else: - self.log.debug('Available metadata: %s', tt) # pylint: disable=no-member + self.log.debug('Available metadata: %s', tt) + self.use_mbid = Meta.use_mbid = True else: self.log.warning('Use of MusicBrainzIdentifier disabled!') self.log.info('Consider using MusicBrainzIdentifier for your music library') + self.use_mbid = Meta.use_mbid = False self._reset_cache() # ######### / Overriding MPDClient #########