Catch KeyError in self.status[status["state"]].

This commit is contained in:
ncoop 2016-07-30 08:18:01 -07:00
parent 40b9283840
commit 54dfb17ecc

View File

@ -90,6 +90,7 @@ class MPD(IntervalModule):
def run(self): def run(self):
try: try:
status = self._mpd_command(self.s, "status") status = self._mpd_command(self.s, "status")
playback_state = status["state"]
currentsong = self._mpd_command(self.s, "currentsong") currentsong = self._mpd_command(self.s, "currentsong")
except Exception: except Exception:
if self.hide_inactive: if self.hide_inactive:
@ -103,7 +104,7 @@ class MPD(IntervalModule):
fdict = { fdict = {
"pos": int(status.get("song", 0)) + 1, "pos": int(status.get("song", 0)) + 1,
"len": int(status.get("playlistlength", 0)), "len": int(status.get("playlistlength", 0)),
"status": self.status[status["state"]], "status": self.status[playback_state],
"volume": int(status.get("volume", 0)), "volume": int(status.get("volume", 0)),
"title": currentsong.get("Title", ""), "title": currentsong.get("Title", ""),