From: kaliko Date: Mon, 21 Dec 2020 15:15:13 +0000 (+0100) Subject: Ensure in MPD filters there is at least the minimum metadata needed X-Git-Tag: 0.16.1~5 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=00b983c12bf5d0b9b94086a444bfd425a31593cd;p=mpd-sima.git Ensure in MPD filters there is at least the minimum metadata needed --- 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