[gnome-music/wip/jfelder/mpris-cleanup: 2/13] mpris: Simplify GetPlaylists method



commit 264a3ad5c6d78e40a4dde3ab5412b82d37bbdbd7
Author: Jean Felder <jfelder src gnome org>
Date:   Thu Mar 21 08:56:20 2019 +0100

    mpris: Simplify GetPlaylists method

 gnomemusic/mpris.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 0c1598c7..aaaf685e 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -654,11 +654,18 @@ class MPRIS(DBusInterface):
     def GetPlaylists(self, index, max_count, order, reverse):
         if order != 'Alphabetical':
             return []
+
         playlists = [(self._get_playlist_dbus_path(playlist),
-                      utils.get_media_title(playlist) or '', '')
+                      utils.get_media_title(playlist), '')
                      for playlist in self.playlists]
-        return playlists[index:index + max_count] if not reverse \
-            else playlists[index + max_count - 1:index - 1 if index - 1 >= 0 else None:-1]
+
+        if not reverse:
+            return playlists[index:index + max_count]
+
+        first_index = index-1
+        if first_index < 0:
+            first_index = None
+        return playlists[index + max_count - 1:first_index:-1]
 
     def PlaylistChanged(self, playlist):
         self.con.emit_signal(None,


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