summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2014-08-29 04:43:40 +0300
committerKai Huuhko <kai.huuhko@gmail.com>2014-08-29 04:43:40 +0300
commit0432a8ab0a4b025431a328cbe82edf2348c32e92 (patch)
tree89f46831424a0da8cc428b7d5591dbad200f7ff6
parent8d46a4c99ed440eada03bc149c507778ab084e8c (diff)
Fix metadata updates
-rw-r--r--valosoitin/ValoDBus.py8
-rwxr-xr-xvalosoitin/Valosoitin.py58
-rw-r--r--valosoitin/gui/playlist.py2
3 files changed, 48 insertions, 20 deletions
diff --git a/valosoitin/ValoDBus.py b/valosoitin/ValoDBus.py
index feec2e2..d37ee39 100644
--- a/valosoitin/ValoDBus.py
+++ b/valosoitin/ValoDBus.py
@@ -101,7 +101,13 @@ class ValosoitinDBus(dbus.service.Object):
101 elif interface == "org.mpris.MediaPlayer2.Player": 101 elif interface == "org.mpris.MediaPlayer2.Player":
102 return self.playerprops 102 return self.playerprops
103 103
104 @dbus.service.signal(dbus.PROPERTIES_IFACE,
105 signature='sa{sv}as')
106 def PropertiesChanged(self, interface_name, changed_properties,
107 invalidated_properties):
108 pass
104 109
110 # === Main MPRIS interface ===
105 @dbus.service.method(dbus_interface='org.mpris.MediaPlayer2', 111 @dbus.service.method(dbus_interface='org.mpris.MediaPlayer2',
106 in_signature='', out_signature='') 112 in_signature='', out_signature='')
107 def Raise(self): 113 def Raise(self):
@@ -112,7 +118,7 @@ class ValosoitinDBus(dbus.service.Object):
112 def Quit(self): 118 def Quit(self):
113 self.parent.quit() 119 self.parent.quit()
114 120
115 121 # === Player interface ===
116 @dbus.service.method(dbus_interface='org.mpris.MediaPlayer2.Player', 122 @dbus.service.method(dbus_interface='org.mpris.MediaPlayer2.Player',
117 in_signature='', out_signature='') 123 in_signature='', out_signature='')
118 def Next(self): 124 def Next(self):
diff --git a/valosoitin/Valosoitin.py b/valosoitin/Valosoitin.py
index ff024f9..6a6bde4 100755
--- a/valosoitin/Valosoitin.py
+++ b/valosoitin/Valosoitin.py
@@ -436,7 +436,7 @@ class Valosoitin(object):
436 except KeyError: 436 except KeyError:
437 log.exception("Item for {0} not found".format(f)) 437 log.exception("Item for {0} not found".format(f))
438 438
439 self.player.file_set("file://"+urllib.quote(f)) 439 self.player.file_set("file://"+urllib.quote(f.encode("utf-8")))
440 if not paused: 440 if not paused:
441 self.play() 441 self.play()
442 #self.player.position = 0.0 442 #self.player.position = 0.0
@@ -478,9 +478,13 @@ class Valosoitin(object):
478 f = urllib.unquote(fn).split("://")[1] 478 f = urllib.unquote(fn).split("://")[1]
479 m = self.library[f] 479 m = self.library[f]
480 480
481 titles = cgi.escape(", ".join(m.get("title"))) if m.get("title") else os.path.splitext(os.path.basename(m.filename))[0] 481 titles = m.get("title", [os.path.splitext(os.path.basename(m.filename))[0]])
482 artists = cgi.escape(", ".join(m.get("artist"))) if m.get("artist") else "" 482 artists = m.get("artist", [""])
483 albums = cgi.escape(", ".join(m.get("album"))) if m.get("album") else "" 483 albums = m.get("album", [""])
484
485 titles = cgi.escape(", ".join(titles))
486 albums = cgi.escape(", ".join(albums))
487 artists = cgi.escape(", ".join(artists))
484 488
485 notify(_("You're listening to"), "\n".join(filter(None, (artists, titles, albums))), "notification-information") 489 notify(_("You're listening to"), "\n".join(filter(None, (artists, titles, albums))), "notification-information")
486 490
@@ -598,22 +602,40 @@ class Valosoitin(object):
598 log.error("Got playing signal but no file set") 602 log.error("Got playing signal but no file set")
599 return 603 return
600 604
601 f = urllib.unquote(fn).split("://")[1] 605 f = urllib.unquote(fn.decode("utf-8")).split("://")[1]
602 m = self.library[f] 606 m = self.library[f]
603 607
604 titles = cgi.escape(", ".join(m.get("title"))) if m.get("title") else os.path.splitext(os.path.basename(m.filename))[0] 608 titles = m.get("title", [os.path.splitext(os.path.basename(m.filename))[0]])
605 artists = cgi.escape(", ".join(m.get("artist"))) if m.get("artist") else "" 609 artists = m.get("artist", [""])
606 albums = cgi.escape(", ".join(m.get("album"))) if m.get("album") else "" 610 albums = m.get("album", [""])
607 611
608 self.audioinfo.title.text = _("title <b>{0}</b>").format(titles) 612 titles = cgi.escape(", ".join(titles))
609 self.audioinfo.artist.text = _("by <i>{0}</i>").format(artists) if artists else "" 613 albums = cgi.escape(", ".join(albums))
610 self.audioinfo.album.text = _("from the album <b>{0}</b>").format(albums) if albums else "" 614
611 615 metadata = dbus.Dictionary({
612 self.dbo.playerprops["Metadata"]["mpris:trackid"] = f 616 "mpris:trackid": dbus.String(f),
613 617 "xesam:title": dbus.String(titles),
614 self.dbo.playerprops["Metadata"]["xesam:title"] = titles 618 "xesam:artist": dbus.Array(artists, signature="s"),
615 self.dbo.playerprops["Metadata"]["xesam:artist"] = artists 619 "xesam:album": dbus.String(albums)
616 self.dbo.playerprops["Metadata"]["xesam:album"] = albums 620 }, signature="sv")
621
622 self.dbo.playerprops["Metadata"] = metadata
623
624 self.dbo.PropertiesChanged(
625 "org.mpris.MediaPlayer2.Player", {"Metadata": metadata}, []
626 )
627
628 artists = cgi.escape(", ".join(artists))
629
630 self.audioinfo.title.text = _(
631 "title <b>{0}</b>"
632 ).format(titles)
633 self.audioinfo.artist.text = _(
634 "by <i>{0}</i>"
635 ).format(artists) if artists else ""
636 self.audioinfo.album.text = _(
637 "from the album <b>{0}</b>"
638 ).format(albums) if albums else ""
617 639
618 if not player.play: 640 if not player.play:
619 log.error("Got playing signal but play state is paused") 641 log.error("Got playing signal but play state is paused")
diff --git a/valosoitin/gui/playlist.py b/valosoitin/gui/playlist.py
index 6ea4695..90c1425 100644
--- a/valosoitin/gui/playlist.py
+++ b/valosoitin/gui/playlist.py
@@ -196,7 +196,7 @@ class PlayListItemClass(elm.GenlistItemClass):
196 196
197 if part == "elm.swallow.icon": 197 if part == "elm.swallow.icon":
198 ic = elm.Icon(genlist) 198 ic = elm.Icon(genlist)
199 if player.file_get() == "file://"+urllib.quote(m.filename): 199 if player.file_get() == "file://"+urllib.quote(m.filename.encode("utf-8")):
200 ic.standard_set("media-playback-start") 200 ic.standard_set("media-playback-start")
201 else: 201 else:
202 ic.standard_set("media-playback-pause") 202 ic.standard_set("media-playback-pause")