[gnome-music/wip/jfelder/mpris-limit-get-songs: 8/12] mpris: Simplify _get_song_dbus_path logic



commit cb30cbaec7e7e3b825123fae5e75c19dc5c59db4
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Oct 24 12:25:02 2018 +0200

    mpris: Simplify _get_song_dbus_path logic

 gnomemusic/mpris.py | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 7f7d7ffe..3dae302d 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -23,8 +23,6 @@
 # code, but you are not obligated to do so.  If you do not wish to do so,
 # delete this exception statement from your version.
 
-import codecs
-
 from gnomemusic.gstplayer import Playback
 from gnomemusic.player import PlayerField, PlayerPlaylist, RepeatMode
 from gnomemusic.grilo import grilo
@@ -349,13 +347,11 @@ class MediaPlayer2Service(Server):
         :return: a D-Bus id to uniquely identify the song
         :rtype: str
         """
-        if media:
-            path = "/org/gnome/GnomeMusic/Tracklist/{}".format(
-                codecs.encode(
-                    bytes(media.get_id(), 'ascii'), 'hex').decode('ascii'))
-        else:
-            path = "/org/mpris/MediaPlayer2/TrackList/NoTrack"
+        if not media:
+            return "/org/mpris/MediaPlayer2/TrackList/NoTrack"
 
+        id_hex = media.get_id().encode('ascii').hex()
+        path = "/org/gnome/GnomeMusic/Tracklist/{}".format(id_hex)
         return path
 
     @log


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]