21 lines
666 B
Python
Executable File
21 lines
666 B
Python
Executable File
#!/usr/bin/env python3
|
|
import dbus
|
|
session_bus = dbus.SessionBus()
|
|
spotify_bus = session_bus.get_object("org.mpris.MediaPlayer2.spotify",
|
|
"/org/mpris/MediaPlayer2")
|
|
spotify_properties = dbus.Interface(spotify_bus,
|
|
"org.freedesktop.DBus.Properties")
|
|
metadata = spotify_properties.Get("org.mpris.MediaPlayer2.Player", "Metadata")
|
|
|
|
# The property Metadata behaves like a python dict
|
|
# for key, value in metadata.items():
|
|
# print(key, value)
|
|
|
|
# To just print the title
|
|
print("{}: {} - [{}]".format(
|
|
metadata['xesam:artist'][0],
|
|
metadata['xesam:title'],
|
|
metadata['xesam:album']
|
|
))
|
|
|