[gnome-music/wip/gbsneto/contained-playlists: 23/35] grilo: Only query user-defined playlists



commit 16455c792c063c84984358576e809f25dea85ef1
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Dec 1 11:15:20 2016 -0200

    grilo: Only query user-defined playlists
    
    Since the Grilo backend queries all the playlists,
    including the static ones, we end up with double
    entries in the playlists view.
    
    Fix that by querying only the user playlists with
    grilo, and letting the Playlists class query the
    static playlists manually.

 gnomemusic/grilo.py |    4 ++--
 gnomemusic/query.py |    9 +++++++--
 2 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index 432e034..eeae128 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -253,8 +253,8 @@ class Grilo(GObject.GObject):
     @log
     def populate_playlists(self, offset, callback, count=-1):
         if self.tracker:
-            GLib.idle_add(self.populate_items, Query.all_playlists(), offset,
-                                                callback, count)
+            GLib.idle_add(self.populate_items, Query.all_user_playlists(),
+                          offset, callback, count)
 
     @log
     def populate_album_songs(self, album, callback, count=-1):
diff --git a/gnomemusic/query.py b/gnomemusic/query.py
index 2992080..a257247 100644
--- a/gnomemusic/query.py
+++ b/gnomemusic/query.py
@@ -111,8 +111,13 @@ class Query():
         return Query.songs('?song a nmm:MusicPiece ; a nfo:FileDataObject .')
 
     @staticmethod
-    def all_playlists():
-        return Query.playlists('?playlist a nmm:Playlist .')
+    def all_user_playlists():
+        query = """
+        ?playlist a nmm:Playlist .
+        FILTER (NOT EXISTS { ?playlist nao:hasTag ?tag })
+        """
+
+        return Query.playlists(query)
 
     @staticmethod
     def all_songs_count():


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