From 9fed2a710b33d6e6125f2856005ea728d7866c13 Mon Sep 17 00:00:00 2001 From: ABelliqueux Date: Fri, 6 Sep 2024 21:11:23 +0200 Subject: [PATCH] Add checks before access --- mpdlisten.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mpdlisten.py b/mpdlisten.py index 5504a79..ec5b287 100755 --- a/mpdlisten.py +++ b/mpdlisten.py @@ -210,9 +210,13 @@ def update_display(device, currentsong:dict, status:dict, mode:str, cursor_pos:i draw = ImageDraw.Draw(ui) if mode == 'playback': if len(currentsong): - draw.text((ui_text_x, 2), currentsong['artist'], fill="white", font=jfont) - draw.text((ui_text_x, 14), currentsong['title'], fill="white", font=jfont) - draw.text((ui_text_x, 26), currentsong['album'], fill="white", font=jfont) + # ~ draw.text((ui_text_x, 2), currentsong['artist'], fill="white", font=jfont) + # ~ draw.text((ui_text_x, 14), currentsong['title'], fill="white", font=jfont) + # ~ draw.text((ui_text_x, 26), currentsong['album'], fill="white", font=jfont) + if 'artist' in currentsong: + draw.text((ui_text_x, 2), currentsong['artist'], fill="white", font=jfont) + if 'title' in currentsong: + draw.text((ui_text_x, 14), currentsong['title'], fill="white", font=jfont) if 'elapsed' in status: draw.text((ui_text_x, 38), "{}/{}".format(sectomin(status['elapsed']), sectomin(status['duration'])), fill="white", font=jfont) elif mode == 'browse':