Now playing: be more tolerant for mpris properties
Some mpris clients dont implement all properties
This commit is contained in:
parent
ad2f08e89b
commit
be83476aef
@ -100,14 +100,20 @@ class NowPlaying(IntervalModule):
|
|||||||
try:
|
try:
|
||||||
player = self.get_player()
|
player = self.get_player()
|
||||||
properties = dbus.Interface(player, "org.freedesktop.DBus.Properties")
|
properties = dbus.Interface(player, "org.freedesktop.DBus.Properties")
|
||||||
get_prop = functools.partial(properties.Get, "org.mpris.MediaPlayer2.Player")
|
|
||||||
|
def get_prop(name, default=None):
|
||||||
|
try:
|
||||||
|
return properties.Get("org.mpris.MediaPlayer2.Player", name)
|
||||||
|
except dbus.exceptions.DBusException:
|
||||||
|
return default
|
||||||
|
|
||||||
currentsong = get_prop("Metadata")
|
currentsong = get_prop("Metadata")
|
||||||
|
|
||||||
fdict = {
|
fdict = {
|
||||||
"status": self.status[self.statusmap[get_prop("PlaybackStatus")]],
|
"status": self.status[self.statusmap[get_prop("PlaybackStatus")]],
|
||||||
"len": 0, # TODO: Use optional(!) TrackList interface for this to gain 100 % mpd<->now_playing compat
|
"len": 0, # TODO: Use optional(!) TrackList interface for this to gain 100 % mpd<->now_playing compat
|
||||||
"pos": 0,
|
"pos": 0,
|
||||||
"volume": int(get_prop("Volume") * 100),
|
"volume": int(get_prop("Volume", 0) * 100),
|
||||||
|
|
||||||
"title": currentsong.get("xesam:title", ""),
|
"title": currentsong.get("xesam:title", ""),
|
||||||
"album": currentsong.get("xesam:album", ""),
|
"album": currentsong.get("xesam:album", ""),
|
||||||
|
Loading…
Reference in New Issue
Block a user