]> kaliko git repositories - mpd-sima.git/commitdiff
Ensure metadata used in filter are available (closes #38)
authorkaliko <kaliko@azylum.org>
Wed, 16 Dec 2020 13:03:50 +0000 (14:03 +0100)
committerkaliko <kaliko@azylum.org>
Wed, 16 Dec 2020 13:03:50 +0000 (14:03 +0100)
doc/Changelog
sima/mpdclient.py
sima/plugins/internal/tags.py

index 70dd3bd9a8b5282d4451129164ef4ef6427cc4d5..d08b7b2c80ec53c44c025e0d548cb0f7a6397da0 100644 (file)
@@ -1,6 +1,7 @@
 MPD_sima v0.16.1
 
 MPD_sima v0.16.1
 
- * 
+ * tags plugin: Ensure metadata used in filter are enabled
+ so that MPD exposes them (closes #38)
 
  -- kaliko <kaliko@azylum.org>  UNRELEASED
 
 
  -- kaliko <kaliko@azylum.org>  UNRELEASED
 
index 0f91380b43da135aa8dfd6631f35f1c513f26f81..0d0ff1e4d4ddd2d87651e84cfc5b1969248dc555 100644 (file)
@@ -124,6 +124,13 @@ class MPD(MPDClient):
     needed_tags = {'Artist', 'Album', 'AlbumArtist', 'Title', 'Track'}
     needed_mbid_tags = {'MUSICBRAINZ_ARTISTID', 'MUSICBRAINZ_ALBUMID',
                         'MUSICBRAINZ_ALBUMARTISTID', 'MUSICBRAINZ_TRACKID'}
     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):
     database = None
 
     def __init__(self, daemon):
index 5cad0e821652069a0a057eb1374c1211a17d6df2..5ea4726837d2462917fd0c4c028e418b5d13e775 100644 (file)
@@ -62,8 +62,8 @@ class Tags(Plugin):
         super().__init__(daemon)
         self.daemon = daemon
         self._control_conf()
         super().__init__(daemon)
         self.daemon = daemon
         self._control_conf()
-        self._setup_tagsneeded()
         self.mpd_filter = forge_filter(self.plugin_conf)
         self.mpd_filter = forge_filter(self.plugin_conf)
+        self._setup_tagsneeded()
         self.log.debug('mpd filter: %s', self.mpd_filter)
 
     def _control_conf(self):
         self.log.debug('mpd filter: %s', self.mpd_filter)
 
     def _control_conf(self):
@@ -82,9 +82,14 @@ class Tags(Plugin):
             raise PluginException('plugin misconfiguration')
 
     def _setup_tagsneeded(self):
             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
 
         tags = config_tags & Tags.supported_tags
         self.player.needed_tags |= tags