diff options
| author | 2016-04-05 18:42:36 +0100 | |
|---|---|---|
| committer | 2016-04-05 18:42:36 +0100 | |
| commit | e1188e153a5e3296469aae8c159d3c6d985ed582 (patch) | |
| tree | abdb02d2860d483274b0b6b29658536b632cd074 | |
| parent | used set.py as an example for the new usage command. (diff) | |
fixed a crash-causing bug in lastfm when userplaycount isn't present.
| -rw-r--r-- | modules/lastfm.py | 11 |
1 files 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( |
