[gnome-music/wip/jfelder/tracker3-rebased: 9/49] grltrackerwrapper: Port artists queries to new Tracker/Grilo expectatives




commit a4c2d77d6e8b7db5e592cb126594e099535161ff
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 797bfde6..87771e0d 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -247,24 +247,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()
         }
 
@@ -563,25 +571,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]