[gnome-music/wip/jfelder/tracker3: 8/24] grltrackerwrapper: Port artist albums query to new Tracker/Grilo expectatives




commit 6175c0947088dd6d516a86dc1a2d0510a2cd7102
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 ba3f7a07..0c600465 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -600,25 +600,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:artist ?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]