From 4cf64095fff807166e189970d92cf12704360c08 Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 15 Jul 2021 07:42:15 +0200 Subject: [PATCH] LastFM: handle the case where a song has no tags --- LastFM/plugin.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/LastFM/plugin.py b/LastFM/plugin.py index 6fa4073..34f21f8 100644 --- a/LastFM/plugin.py +++ b/LastFM/plugin.py @@ -143,10 +143,13 @@ class LastFM(callbacks.Plugin): # We currently show play count and tags - more could be added in the future... userplaycount = ext_data['userplaycount'] - tags = [tag['name'] for tag in ext_data['toptags']['tag']] + if ext_data['toptags']: + tags = [tag['name'] for tag in ext_data['toptags']['tag']] + else: + tags = [] ext_info = ' (Playcount: %s / Tags: %s)' % (userplaycount, ', '.join(tags) or 'N/A') - except KeyError: - pass + except KeyError as e: + log.debug("LastFM: error getting extended info", exc_info=True) if time is None: s = '%s is listening to %s by %s %s %s. %s' % (ircutils.bold(user), ircutils.bold(track),