fixed a crash-causing bug in lastfm when userplaycount isn't present.

This commit is contained in:
jesopo 2016-04-05 18:42:36 +01:00
parent efa8c91552
commit e1188e153a
No known key found for this signature in database
GPG key ID: 0BBDEB2AEFCFFCB3

View file

@ -47,12 +47,15 @@ class Module(object):
tags = " (%s)" % ", ".join(tags)
else:
tags = ""
play_count = ""
if "userplaycount" in info_page["track"]:
play_count = int(info_page["track"]["userplaycount"])
play_count = "%d play%s" % (play_count,
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(