From 5c2af069af7690aaaa271dd771f6699ca0e6e4e2 Mon Sep 17 00:00:00 2001 From: enkore Date: Mon, 4 Aug 2014 03:05:43 +0200 Subject: [PATCH] Fixed various issues in now_playing --- i3pystatus/now_playing.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/i3pystatus/now_playing.py b/i3pystatus/now_playing.py index 143f986..5cdfec9 100644 --- a/i3pystatus/now_playing.py +++ b/i3pystatus/now_playing.py @@ -57,6 +57,8 @@ class NowPlaying(IntervalModule): players = [a for a in dbus.SessionBus().get_object("org.freedesktop.DBus", "/org/freedesktop/DBus").ListNames() if a.startswith("org.mpris.MediaPlayer2.")] if self.old_player in players: return self.old_player + if not players: + raise dbus.exceptions.DBusException() self.old_player = players[0] return players[0] @@ -90,14 +92,14 @@ class NowPlaying(IntervalModule): "title":currentsong.get("xesam:title", ""), "album": currentsong.get("xesam:album", ""), "artist": ", ".join(currentsong.get("xesam:artist", "")), - "song_length": TimeWrapper(currentsong.get("mpris:length") / 1000**2), - "song_elapsed": TimeWrapper(get_prop("Position") / 1000**2), + "song_length": TimeWrapper((currentsong.get("mpris:length") or 0) / 1000**2), + "song_elapsed": TimeWrapper((get_prop("Position") or 0) / 1000**2), "filename": "", } if not fdict["title"]: fdict["filename"] = '.'.join( - basename(currentsong["xesam:url"]).split('.')[:-1]) + basename((currentsong.get("xesam:url") or "")).split('.')[:-1]) self.output = { "full_text": formatp(self.format, **fdict).strip(),