[gnome-music/wip/carlosg/tracker3: 56/68] grltrackerwrapper: Port album queries to new Tracker/Grilo expectatives



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

    grltrackerwrapper: Port album 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 | 91 +++++++++++++++++----------
 1 file changed, 58 insertions(+), 33 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index de0ca29c..dbffcf4e 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -175,24 +175,36 @@ class GrlTrackerWrapper(GObject.GObject):
 
         query = """
         SELECT
-            rdf:type(?album)
-            tracker:id(?album) AS ?id
-            nie:title(?album) AS ?title
-            ?composer AS ?composer
-            ?album_artist AS ?album_artist
-            nmm:artistName(?performer) AS ?artist
-            nie:url(?song) AS ?url
-            YEAR(MAX(nie:contentCreated(?song))) AS ?creation_date
+            ?type ?id ?title ?composer ?albumArtist
+            ?artist ?url ?creationDate
         WHERE {
-            ?album a nmm:MusicAlbum .
-            ?song a nmm:MusicPiece ;
-                    nmm:musicAlbum ?album ;
-                    nmm:performer ?performer .
-            OPTIONAL { ?song nmm:composer/nmm:artistName ?composer . }
-            OPTIONAL { ?album nmm:albumArtist/nmm:artistName ?album_artist . }
-            %(location_filter)s
-        } GROUP BY ?album
+            SERVICE <dbus:org.freedesktop.Tracker3.Miner.Files> {
+                GRAPH tracker:Audio {
+                    SELECT
+                        %(media_type)s AS ?type
+                        ?album AS ?id
+                        nie:title(?album) AS ?title
+                        ?composer
+                        ?albumArtist
+                        nmm:artistName(?performer) AS ?artist
+                        nie:isStoredAs(?song) AS ?url
+                        YEAR(MAX(nie:contentCreated(?song))) AS ?creationDate
+                    WHERE {
+                        ?album a nmm:MusicAlbum .
+                        ?song a nmm:MusicPiece ;
+                                nmm:musicAlbum ?album ;
+                                nmm:performer ?performer .
+                        OPTIONAL { ?song nmm:composer/
+                                         nmm:artistName ?composer . }
+                        OPTIONAL { ?album nmm:albumArtist/
+                                          nmm:artistName ?albumArtist . }
+                        %(location_filter)s
+                    } GROUP BY ?album
+                }
+            }
+        }
         """.replace('\n', ' ').strip() % {
+            'media_type': int(Grl.MediaType.CONTAINER),
             'location_filter': self._tracker_wrapper.location_filter()
         }
 
@@ -573,27 +585,40 @@ class GrlTrackerWrapper(GObject.GObject):
 
         query = """
         SELECT
-            rdf:type(?album)
-            tracker:id(?album) AS ?id
-            nie:title(?album) AS ?title
-            ?composer AS ?composer
-            ?album_artist AS ?album_artist
-            nmm:artistName(?performer) AS ?artist
-            nie:url(?song) AS ?url
-            YEAR(MAX(nie:contentCreated(?song))) AS ?creation_date
+            ?type ?id ?title ?composer ?albumArtist
+            ?artist ?url ?creationDate
         WHERE
         {
-            ?album a nmm:MusicAlbum .
-            ?song a nmm:MusicPiece ;
-                    nmm:musicAlbum ?album ;
-                    nmm:performer ?performer .
-            OPTIONAL { ?song nmm:composer/nmm:artistName ?composer . }
-            OPTIONAL { ?album nmm:albumArtist/nmm:artistName ?album_artist . }
-            %(location_filter)s
+            SERVICE <dbus:org.freedesktop.Tracker3.Miner.Files> {
+                GRAPH tracker:Audio {
+                    SELECT
+                        %(media_type)s AS ?type
+                        ?album AS ?id
+                        nie:title(?album) AS ?title
+                        ?composer
+                        ?albumArtist
+                        nmm:artistName(?performer) AS ?artist
+                        nie:isStoredAs(?song) AS ?url
+                        YEAR(MAX(nie:contentCreated(?song))) AS ?creationDate
+                    WHERE
+                    {
+                        ?album a nmm:MusicAlbum .
+                        ?song a nmm:MusicPiece ;
+                                nmm:musicAlbum ?album ;
+                                nmm:performer ?performer .
+                        OPTIONAL { ?song nmm:composer/
+                                         nmm:artistName ?composer . }
+                        OPTIONAL { ?album nmm:albumArtist/
+                                          nmm:artistName ?albumArtist . }
+                        %(location_filter)s
+                    }
+                    GROUP BY ?album
+                    ORDER BY ?title ?albumArtist ?artist ?creationDate
+                }
+            }
         }
-        GROUP BY ?album
-        ORDER BY ?title ?album_artist ?artist ?creation_date
         """.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]