From e1188e153a5e3296469aae8c159d3c6d985ed582 Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 5 Apr 2016 18:42:36 +0100 Subject: [PATCH] fixed a crash-causing bug in lastfm when userplaycount isn't present. --- modules/lastfm.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/lastfm.py b/modules/lastfm.py index ed470704..c942d394 100644 --- a/modules/lastfm.py +++ b/modules/lastfm.py @@ -47,12 +47,15 @@ class Module(object): tags = " (%s)" % ", ".join(tags) else: tags = "" - play_count = int(info_page["track"]["userplaycount"]) - play_count = "%d play%s" % (play_count, - "s" if play_count > 1 else "") + + play_count = "" + if "userplaycount" in info_page["track"]: + play_count = int(info_page["track"]["userplaycount"]) + play_count = " (%d play%s)" % (play_count, + "s" if play_count > 1 else "") event["stdout"].write( - "%s is now playing: %s - %s (%s)%s" % ( + "%s is now playing: %s - %s%s%s" % ( username, artist, track_name, play_count, tags)) else: event["stderr"].write(