aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2016-04-06 16:22:52 +0100
committerGravatar jesopo2016-04-06 16:22:52 +0100
commit3ba307300f5543691c01f5cfb40c7d5edf72ae61 (patch)
tree013dc1a871d49cc9d17d97dac9cb1f47a98317f0
parentadded an extra check related to the --require-config hashflag, causing a non-... (diff)
added more code to deal with lastfm having a ridiculously unreliably structured API.
-rw-r--r--modules/lastfm.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/lastfm.py b/modules/lastfm.py
index 7b56bfbd..77f693c1 100644
--- a/modules/lastfm.py
+++ b/modules/lastfm.py
@@ -41,7 +41,7 @@ class Module(object):
"api_key": self.bot.config["lastfm-api-key"],
"user": username, "format": "json"}, json=True)
tags = []
- if "toptags" in info_page["track"]:
+ if "toptags" in info_page.get("track", []):
for tag in info_page["track"]["toptags"]["tag"]:
tags.append(tag["name"])
if tags:
@@ -50,7 +50,7 @@ class Module(object):
tags = ""
play_count = ""
- if "userplaycount" in info_page["track"]:
+ if "userplaycount" in info_page.get("track", []):
play_count = int(info_page["track"]["userplaycount"])
play_count = " (%d play%s)" % (play_count,
"s" if play_count > 1 else "")