X-Git-Url: http://git.kaliko.me/?a=blobdiff_plain;f=sima%2Fplugins%2Finternal%2Ftags.py;h=5ea4726837d2462917fd0c4c028e418b5d13e775;hb=e4dc436d9891dd6f7b80c8d60d45bbc39b7c67d3;hp=6a2acf74c010d6cc5103f526bc55709268e90ff7;hpb=45a6d5d8e466f8c82e3d85c3442c7e437a449b6e;p=mpd-sima.git diff --git a/sima/plugins/internal/tags.py b/sima/plugins/internal/tags.py index 6a2acf7..5ea4726 100644 --- a/sima/plugins/internal/tags.py +++ b/sima/plugins/internal/tags.py @@ -32,6 +32,7 @@ from ...lib.plugin import Plugin from ...lib.track import Track from ...utils.utils import PluginException + def forge_filter(cfg): tags = set(cfg.keys()) & Tags.supported_tags cfg_filter = cfg.get('filter', None) @@ -61,8 +62,8 @@ class Tags(Plugin): super().__init__(daemon) self.daemon = daemon self._control_conf() - self._setup_tagsneeded() self.mpd_filter = forge_filter(self.plugin_conf) + self._setup_tagsneeded() self.log.debug('mpd filter: %s', self.mpd_filter) def _control_conf(self): @@ -81,9 +82,14 @@ class Tags(Plugin): raise PluginException('plugin misconfiguration') def _setup_tagsneeded(self): - config_tags = {k for k, v in self.plugin_conf.items() if v} - self.log.debug('%s plugin needs the followinng metadata: %s', - self, config_tags & Tags.supported_tags) + """Ensure needed tags are exposed by MPD""" + # At this point mpd_filter concatenetes {tags}+filter + config_tags = set() + for mpd_supp_tags in self.player.MPD_supported_tags: + if mpd_supp_tags.lower() in self.mpd_filter.lower(): + config_tags.add(mpd_supp_tags.lower()) + self.log.debug('%s plugin needs the following metadata: %s', + self, config_tags) tags = config_tags & Tags.supported_tags self.player.needed_tags |= tags @@ -98,8 +104,9 @@ class Tags(Plugin): def start(self): if (0, 21, 0) > tuple(map(int, self.player.mpd_version.split('.'))): self.log.warning('MPD protocol version: %s < 0.21.0', - self.player.mpd_version) - self.log.error('Need at least MPD 0.21 to use Tags plugin (filters required)') + self.player.mpd_version) + self.log.error( + 'Need at least MPD 0.21 to use Tags plugin (filters required)') self.player.disconnect() raise PluginException('MPD >= 0.21 required') # Check filter is valid