]> kaliko git repositories - mpd-sima.git/commitdiff
Ensure in MPD filters there is at least the minimum metadata needed
authorkaliko <kaliko@azylum.org>
Mon, 21 Dec 2020 15:15:13 +0000 (16:15 +0100)
committerkaliko <kaliko@azylum.org>
Mon, 21 Dec 2020 15:48:25 +0000 (16:48 +0100)
sima/mpdclient.py
sima/plugins/internal/random.py
sima/plugins/internal/tags.py

index 5c32b775feb9906c6317e44172db3cb9838655ea..4634025134a5571f4a43efa28265a1f465dc607d 100644 (file)
@@ -482,8 +482,9 @@ class MPD(MPDClient):
             self.log.debug('Searching album for %s aliases: "%s"',
                            artist, artist.aliases)
         for name_sz in artist.names_sz:
-            raw_albums = self.list('album', f"( albumartist == '{name_sz}')")
-            albums = [Album(a, albumartist=artist.name, artist=artist) for a in raw_albums if a]
+            mpd_filter = f"((albumartist == '{name_sz}') AND ( album != ''))"
+            raw_albums = self.list('album', mpd_filter)
+            albums = [Album(a, albumartist=artist.name, artist=artist) for a in raw_albums]
         candidates = []
         for album in albums:
             album_trks = self.find_tracks(album)
index 815824358b8975369ee97ee2bc8cec7bd0a6c1de..bb9239669e38a9827e75739b0e7c59de66a62b8c 100644 (file)
@@ -77,7 +77,7 @@ class Random(Plugin):
         self.candidates = []
         trks = []
         target = self.plugin_conf.getint('track_to_add')
-        artists = self.player.list('artist')
+        artists = self.player.list('artist', '( artist != "")')
         random.shuffle(artists)
         for art in artists:
             if self.filtered_artist(art):
index ad326ef3a1f3f587c3ba6c89332a847aaa072426..e0d26d2f277f4ae3540f4f63f7211e09823f003a 100644 (file)
@@ -48,8 +48,8 @@ def forge_filter(cfg):
         else:
             mpd_filter.append(f"({tag} == '{cfg[tag].strip()}')")
     mpd_filter = ' AND '.join(mpd_filter)
-    if 'AND' in mpd_filter:
-        mpd_filter = f'({mpd_filter})'
+    # Ensure there is at least an artist name
+    mpd_filter = f"({mpd_filter} AND (artist != ''))"
     return mpd_filter