[gnome-music/wip/carlosg/tracker3: 57/68] grltrackerwrapper: Port artist albums query to new Tracker/Grilo expectatives



commit 681f46e32124dc1fc87785a134331b5564b64fb3
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun May 31 15:34:31 2020 +0200

    grltrackerwrapper: Port artist albums query to new Tracker/Grilo expectatives
    
    For Tracker 3, the miner service must be queried specifically, and it is better
    to specify here that we are querying from the tracker:Audio graph.
    
    For Grilo, the variable names are slightly different, and IDs are now URNs, not
    tracker:id()s.

 gnomemusic/grilowrappers/grltrackerwrapper.py | 41 ++++++++++++++++-----------
 1 file changed, 25 insertions(+), 16 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index dbffcf4e..54f26438 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -689,25 +689,34 @@ class GrlTrackerWrapper(GObject.GObject):
         artist_id = media.get_id()
 
         query = """
-        SELECT DISTINCT
-            rdf:type(?album)
-            tracker:id(?album) AS ?id
-            nie:title(?album) AS ?title
-            nie:contentCreated(?song) AS ?date
+        SELECT
+            ?type ?id ?title ?creationDate
         WHERE {
-            ?album a nmm:MusicAlbum .
-            OPTIONAL { ?album  nmm:albumArtist ?album_artist . }
-            ?song a nmm:MusicPiece;
-                    nmm:musicAlbum ?album;
-                    nmm:performer ?artist .
-            FILTER ( tracker:id(?album_artist) = %(artist_id)s
-                     || tracker:id(?artist) = %(artist_id)s )
-            %(location_filter)s
+            SERVICE <dbus:org.freedesktop.Tracker3.Miner.Files> {
+                GRAPH tracker:Audio {
+                    SELECT DISTINCT
+                        %(media_type)s AS ?type
+                        ?album AS ?id
+                        nie:title(?album) AS ?title
+                        nie:contentCreated(?song) AS ?creationDate
+                    WHERE {
+                        ?album a nmm:MusicAlbum .
+                        OPTIONAL { ?album  nmm:albumArtist ?album_artist . }
+                        ?song a nmm:MusicPiece;
+                              nmm:musicAlbum ?album;
+                              nmm:performer ?artist .
+                        FILTER ( ?album_artist = <%(artist_id)s>
+                                 || ?artist = <%(artist_id)s> )
+                        %(location_filter)s
+                    }
+                   GROUP BY ?album
+                   ORDER BY ?creationDate ?album
+                }
+            }
         }
-        GROUP BY ?album
-        ORDER BY ?date ?album
         """.replace('\n', ' ').strip() % {
-            'artist_id': int(artist_id),
+            'media_type': int(Grl.MediaType.CONTAINER),
+            'artist_id': artist_id,
             'location_filter': self._tracker_wrapper.location_filter()
         }
 


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