[gnome-music/wip/jfelder/tracker3: 5/24] grltrackerwrapper: Port album discs query to new Tracker/Grilo expectatives




commit 9a2c94a6a707e4ae996b7b2255f49c74a087c1b5
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun May 31 15:17:52 2020 +0200

    grltrackerwrapper: Port album discs 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 | 30 ++++++++++++++++++---------
 1 file changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index ce50bd3e..f7e25e73 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -633,19 +633,29 @@ class GrlTrackerWrapper(GObject.GObject):
         album_id = media.get_id()
 
         query = """
-        SELECT DISTINCT
-            rdf:type(?song)
-            tracker:id(?album) AS ?id
-            nmm:setNumber(nmm:musicAlbumDisc(?song)) as ?album_disc_number
+        SELECT
+            ?type ?id ?albumDiscNumber
         WHERE {
-            ?song a nmm:MusicPiece;
-                    nmm:musicAlbum ?album .
-            FILTER ( tracker:id(?album) = %(album_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
+                        nmm:setNumber(nmm:musicAlbumDisc(?song))
+                            AS ?albumDiscNumber
+                    WHERE {
+                        ?song a nmm:MusicPiece;
+                                nmm:musicAlbum ?album .
+                        FILTER ( ?album = <%(album_id)s> )
+                        %(location_filter)s
+                    }
+                    ORDER BY ?albumDiscNumber
+                }
+            }
         }
-        ORDER BY ?album_disc_number
         """.replace('\n', ' ').strip() % {
-            'album_id': int(album_id),
+            "media_type": int(Grl.MediaType.CONTAINER),
+            "album_id": album_id,
             'location_filter': self._tracker_wrapper.location_filter()
         }
 


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