diff --git a/bin/mpdevil.py b/bin/mpdevil.py index eccfcca..b925c74 100644 --- a/bin/mpdevil.py +++ b/bin/mpdevil.py @@ -33,13 +33,13 @@ import gettext import datetime import os import sys +import re #MPRIS modules import dbus import dbus.service from dbus.mainloop.glib import DBusGMainLoop import base64 -import re DATADIR = '@datadir@' NAME = 'mpdevil' @@ -58,139 +58,6 @@ except locale.Error: gettext.textdomain(PACKAGE) gettext.install(PACKAGE, localedir='@datadir@/locale') -# MPRIS allowed metadata tags -allowed_tags = { - 'mpris:trackid': dbus.ObjectPath, - 'mpris:length': dbus.Int64, - 'mpris:artUrl': str, - 'xesam:album': str, - 'xesam:albumArtist': list, - 'xesam:artist': list, - 'xesam:asText': str, - 'xesam:audioBPM': int, - 'xesam:comment': list, - 'xesam:composer': list, - 'xesam:contentCreated': str, - 'xesam:discNumber': int, - 'xesam:firstUsed': str, - 'xesam:genre': list, - 'xesam:lastUsed': str, - 'xesam:lyricist': str, - 'xesam:title': str, - 'xesam:trackNumber': int, - 'xesam:url': str, - 'xesam:useCount': int, - 'xesam:userRating': float, -} - -# python dbus bindings don't include annotations and properties -MPRIS2_INTROSPECTION = """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -""" - class IntEntry(Gtk.SpinButton): def __init__(self, default, lower, upper, step): Gtk.SpinButton.__init__(self) @@ -441,6 +308,139 @@ class MPRISInterface(dbus.service.Object): #TODO emit Seeked if needed __introspect_interface = "org.freedesktop.DBus.Introspectable" __prop_interface = dbus.PROPERTIES_IFACE + # python dbus bindings don't include annotations and properties + MPRIS2_INTROSPECTION = """ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + """ + + # MPRIS allowed metadata tags + allowed_tags = { + 'mpris:trackid': dbus.ObjectPath, + 'mpris:length': dbus.Int64, + 'mpris:artUrl': str, + 'xesam:album': str, + 'xesam:albumArtist': list, + 'xesam:artist': list, + 'xesam:asText': str, + 'xesam:audioBPM': int, + 'xesam:comment': list, + 'xesam:composer': list, + 'xesam:contentCreated': str, + 'xesam:discNumber': int, + 'xesam:firstUsed': str, + 'xesam:genre': list, + 'xesam:lastUsed': str, + 'xesam:lyricist': str, + 'xesam:title': str, + 'xesam:trackNumber': int, + 'xesam:url': str, + 'xesam:useCount': int, + 'xesam:userRating': float, + } + def __init__(self, window, client, settings): dbus.service.Object.__init__(self, dbus.SessionBus(), "/org/mpris/MediaPlayer2") self._name = "org.mpris.MediaPlayer2.mpdevil" @@ -557,7 +557,7 @@ class MPRISInterface(dbus.service.Object): #TODO emit Seeked if needed # Cast self.metadata to the correct type, or discard it for key, value in self.metadata.items(): try: - self.metadata[key] = allowed_tags[key](value) + self.metadata[key] = self.allowed_tags[key](value) except ValueError: del self.metadata[key] @@ -681,7 +681,7 @@ class MPRISInterface(dbus.service.Object): #TODO emit Seeked if needed @dbus.service.method(__introspect_interface) def Introspect(self): - return MPRIS2_INTROSPECTION + return self.MPRIS2_INTROSPECTION @dbus.service.signal(__prop_interface, signature="sa{sv}as") def PropertiesChanged(self, interface, changed_properties, invalidated_properties):