[gnome-music/wip/carlosg/tracker3: 3/13] grltrackerwrapper: Port artists queries to new Tracker/Grilo expectatives



commit 516628823d4711a4f9f00a815d65eb9233b66bed
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun May 31 15:29:10 2020 +0200

    grltrackerwrapper: Port artists queries 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 | 74 ++++++++++++++++-----------
 1 file changed, 45 insertions(+), 29 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index a139b571..50788cd3 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -248,24 +248,32 @@ class GrlTrackerWrapper(GObject.GObject):
         artist_ids = {}
 
         query = """
-        SELECT
-            rdf:type(?artist)
-            COALESCE(tracker:id(?album_artist), tracker:id(?artist)) AS ?id
-            ?artist_bind AS ?artist
+        SELECT ?type ?id ?artist
         WHERE {
-            ?song a nmm:MusicPiece;
-                    nmm:musicAlbum ?album;
-                    nmm:performer ?artist .
-            OPTIONAL {
-                ?album a nmm:MusicAlbum;
-                         nmm:albumArtist ?album_artist .
+            SERVICE <dbus:org.freedesktop.Tracker3.Miner.Files> {
+                GRAPH tracker:Audio {
+                    SELECT
+                        %(media_type)s AS ?type
+                        (COALESCE(?album_artist, ?artist) AS ?id)
+                        ?artist_bind AS ?albumArtist
+                    WHERE {
+                        ?song a nmm:MusicPiece;
+                                nmm:musicAlbum ?album;
+                                nmm:performer ?artist .
+                        OPTIONAL {
+                            ?album a nmm:MusicAlbum;
+                                     nmm:albumArtist ?album_artist .
+                        }
+                        BIND(COALESCE(nmm:artistName(?album_artist),
+                                      nmm:artistName(?artist)) AS ?artist_bind)
+                        %(location_filter)s
+                    }
+                    GROUP BY ?artist_bind
+                }
             }
-            BIND(COALESCE(nmm:artistName(?album_artist),
-                          nmm:artistName(?artist)) AS ?artist_bind)
-            %(location_filter)s
         }
-        GROUP BY ?artist_bind
         """.replace('\n', ' ').strip() % {
+            'media_type': int(Grl.MediaType.CONTAINER),
             'location_filter': self._tracker_wrapper.location_filter()
         }
 
@@ -651,25 +659,33 @@ class GrlTrackerWrapper(GObject.GObject):
                 artists_added.clear()
 
         query = """
-        SELECT
-            rdf:type(?artist)
-            COALESCE(tracker:id(?album_artist), tracker:id(?artist)) AS ?id
-            ?artist_bind AS ?artist
+        SELECT ?type ?id ?albumArtist
         WHERE {
-            ?song a nmm:MusicPiece;
-                    nmm:musicAlbum ?album;
-                    nmm:performer ?artist .
-            OPTIONAL {
-                ?album a nmm:MusicAlbum;
-                         nmm:albumArtist ?album_artist .
+            SERVICE <dbus:org.freedesktop.Tracker3.Miner.Files> {
+                GRAPH tracker:Audio {
+                    SELECT
+                       %(media_type)s AS ?type
+                       (COALESCE(?album_artist, ?artist) AS ?id)
+                       ?artist_bind AS ?albumArtist
+                    WHERE {
+                        ?song a nmm:MusicPiece;
+                                nmm:musicAlbum ?album;
+                                nmm:performer ?artist .
+                        OPTIONAL {
+                            ?album a nmm:MusicAlbum;
+                                     nmm:albumArtist ?album_artist .
+                        }
+                        BIND(COALESCE(nmm:artistName(?album_artist),
+                                      nmm:artistName(?artist)) AS ?artist_bind)
+                        %(location_filter)s
+                    }
+                    GROUP BY ?artist_bind
+                    ORDER BY ?artist_bind
+                }
             }
-            BIND(COALESCE(nmm:artistName(?album_artist),
-                          nmm:artistName(?artist)) AS ?artist_bind)
-            %(location_filter)s
         }
-        GROUP BY ?artist_bind
-        ORDER BY ?artist_bind
         """.replace('\n', ' ').strip() % {
+            'media_type': int(Grl.MediaType.CONTAINER),
             'location_filter': self._tracker_wrapper.location_filter()
         }
 


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