From 00b983c12bf5d0b9b94086a444bfd425a31593cd Mon Sep 17 00:00:00 2001 From: kaliko Date: Mon, 21 Dec 2020 16:15:13 +0100 Subject: [PATCH] Ensure in MPD filters there is at least the minimum metadata needed --- sima/mpdclient.py | 5 +++-- sima/plugins/internal/random.py | 2 +- sima/plugins/internal/tags.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sima/mpdclient.py b/sima/mpdclient.py index 5c32b77..4634025 100644 --- a/sima/mpdclient.py +++ b/sima/mpdclient.py @@ -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) diff --git a/sima/plugins/internal/random.py b/sima/plugins/internal/random.py index 8158243..bb92396 100644 --- a/sima/plugins/internal/random.py +++ b/sima/plugins/internal/random.py @@ -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): diff --git a/sima/plugins/internal/tags.py b/sima/plugins/internal/tags.py index ad326ef..e0d26d2 100644 --- a/sima/plugins/internal/tags.py +++ b/sima/plugins/internal/tags.py @@ -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 -- 2.39.5