[module/spotify] Add new format string parameter
This commit is contained in:
parent
5d4c9e4a41
commit
2183b229e3
1 changed files with 7 additions and 1 deletions
|
@ -6,6 +6,8 @@ Requires the following library:
|
|||
* python-dbus
|
||||
|
||||
Parameters:
|
||||
* spotify.format: Format string (defaults to "{artist} - {title}")
|
||||
Available values are: {album}, {title}, {artist}, {trackNumber}
|
||||
"""
|
||||
|
||||
import bumblebee.input
|
||||
|
@ -24,6 +26,7 @@ class Module(bumblebee.engine.Module):
|
|||
bumblebee.output.Widget(full_text=self.spotify)
|
||||
)
|
||||
self._song = ""
|
||||
self._format = self.parameter("format", "{artist} - {title}")
|
||||
|
||||
cmd="dbus-send --session --type=method_call --dest=org.mpris.MediaPlayer2.spotify \
|
||||
/org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player."
|
||||
|
@ -43,7 +46,10 @@ class Module(bumblebee.engine.Module):
|
|||
spotify = bus.get_object("org.mpris.MediaPlayer2.spotify", "/org/mpris/MediaPlayer2")
|
||||
spotify_iface = dbus.Interface(spotify, 'org.freedesktop.DBus.Properties')
|
||||
props = spotify_iface.Get('org.mpris.MediaPlayer2.Player', 'Metadata')
|
||||
self._song = (str(props['xesam:artist'][0]) + " - " + str(props['xesam:title']))
|
||||
self._song = self._format.format(album=str(props.get('xesam:album')),
|
||||
title=str(props.get('xesam:title')),
|
||||
artist=','.join(props.get('xesam:artist')),
|
||||
trackNumber=str(props.get('xesam:trackNumber')))
|
||||
except Exception:
|
||||
self._song = ""
|
||||
|
||||
|
|
Loading…
Reference in a new issue