From 61862a67b6507185e03048a1f0e72638688b2de6 Mon Sep 17 00:00:00 2001
From: kaliko <kaliko@azylum.org>
Date: Mon, 7 Jun 2021 21:02:09 +0200
Subject: [PATCH] Use Track Album attribute to avoid missing album name

Track.Album as a fallback is name is not provided.
---
 sima/lib/plugin.py | 12 ++++++------
 sima/mpdclient.py  |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sima/lib/plugin.py b/sima/lib/plugin.py
index db44013..e48cc03 100644
--- a/sima/lib/plugin.py
+++ b/sima/lib/plugin.py
@@ -185,12 +185,12 @@ class AdvancedPlugin(Plugin):
         album_to_queue = []
         for album in albums_not_in_hist:
             # Controls the album found is not already queued
-            if album in {t.album for t in self.player.queue}:
+            if album in {t.Album.name for t in self.player.queue}:
                 self.log.debug('"%s" already queued, skipping!', album)
                 continue
             # In random play mode use complete playlist to filter
             if self.player.playmode.get('random'):
-                if album in {t.album for t in self.player.playlist}:
+                if album in {t.Album.name for t in self.player.playlist}:
                     self.log.debug('"%s" already in playlist, skipping!',
                                    album)
                     continue
@@ -225,10 +225,10 @@ class AdvancedPlugin(Plugin):
         for trk in [_ for _ in not_in_hist if _ not in deny_list]:
             # Should use albumartist heuristic as well
             if self.plugin_conf.getboolean('single_album', False):  # pylint: disable=no-member
-                albums = [tr.album for tr in deny_list]
-                albums += [tr.album for tr in self.to_add]
-                if (trk.album == self.player.current.album or
-                        trk.album in albums):
+                albums = [tr.Album for tr in deny_list]
+                albums += [tr.Album for tr in self.to_add]
+                if (trk.Album == self.player.current.Album or
+                        trk.Album in albums):
                     self.log.debug('Found unplayed track ' +
                                    'but from an album already queued: %s', trk)
                     continue
diff --git a/sima/mpdclient.py b/sima/mpdclient.py
index 92ca0ce..539f8b8 100644
--- a/sima/mpdclient.py
+++ b/sima/mpdclient.py
@@ -316,7 +316,7 @@ class MPD(MPDClient):
         for name in artist.names:
             tracks |= set(self.find('artist', name))
         # album blocklist
-        albums = {Album(trk.album, mbid=trk.musicbrainz_albumid)
+        albums = {Album(trk.Album.name, mbid=trk.musicbrainz_albumid)
                   for trk in tracks}
         bl_albums = {Album(a.get('album'), mbid=a.get('musicbrainz_album'))
                      for a in self.database.view_bl() if a.get('album')}
-- 
2.39.5