[gnome-music/wip/jfelder/tracker3: 11/22] grltrackerwrapper: Port search queries to new Tracker/Grilo expectatives
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/tracker3: 11/22] grltrackerwrapper: Port search queries to new Tracker/Grilo expectatives
- Date: Mon, 24 Aug 2020 16:14:17 +0000 (UTC)
commit 0de980d425df47fbdcf572dd93f5556a54760a9e
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun May 31 16:50:38 2020 +0200
grltrackerwrapper: Port search 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 | 193 +++++++++++++++-----------
1 file changed, 114 insertions(+), 79 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index 24c6e82d..57dafa4c 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -805,39 +805,51 @@ class GrlTrackerWrapper(GObject.GObject):
self._window.notifications_popup.push_loading()
query = """
- SELECT DISTINCT
- rdf:type(?artist)
- COALESCE(tracker:id(?album_artist), tracker:id(?artist)) AS ?id
+ SELECT
+ ?type ?id
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 DISTINCT
+ %(media_type)s AS ?type
+ COALESCE(?album_artist, ?artist) AS ?id
+ WHERE {
+ ?song a nmm:MusicPiece ;
+ nmm:musicAlbum ?album ;
+ nmm:artist ?artist .
+ OPTIONAL {
+ ?album a nmm:MusicAlbum ;
+ nmm:albumArtist ?album_artist .
+ }
+ BIND(COALESCE(nmm:artistName(?album_artist),
+ nmm:artistName(?artist)) AS ?artist_bind)
+ BIND(tracker:normalize(nmm:artistName(
+ nmm:albumArtist(?artist_bind)), 'nfkd')
+ AS ?match1) .
+ BIND(tracker:normalize(
+ nmm:artistName(nmm:artist(?song)), 'nfkd')
+ AS ?match2) .
+ BIND(tracker:normalize(nmm:composer(?song), 'nfkd')
+ AS ?match4) .
+ FILTER (
+ CONTAINS(tracker:case-fold(
+ tracker:unaccent(?match1)), "%(name)s")
+ || CONTAINS(tracker:case-fold(?match1), "%(name)s")
+ || CONTAINS(tracker:case-fold(
+ tracker:unaccent(?match2)), "%(name)s")
+ || CONTAINS(tracker:case-fold(?match2), "%(name)s")
+ || CONTAINS(tracker:case-fold(
+ tracker:unaccent(?match4)), "%(name)s")
+ || CONTAINS(tracker:case-fold(?match4), "%(name)s")
+ )
+ %(location_filter)s
+ }
+ LIMIT 50
+ }
}
- BIND(COALESCE(nmm:artistName(?album_artist),
- nmm:artistName(?artist)) AS ?artist_bind)
- BIND(tracker:normalize(nmm:artistName(
- nmm:albumArtist(?artist_bind)), 'nfkd') AS ?match1) .
- BIND(tracker:normalize(
- nmm:artistName(nmm:performer(?song)), 'nfkd') AS ?match2) .
- BIND(tracker:normalize(nmm:composer(?song), 'nfkd') AS ?match4) .
- FILTER (
- CONTAINS(tracker:case-fold(
- tracker:unaccent(?match1)), "%(name)s")
- || CONTAINS(tracker:case-fold(?match1), "%(name)s")
- || CONTAINS(tracker:case-fold(
- tracker:unaccent(?match2)), "%(name)s")
- || CONTAINS(tracker:case-fold(?match2), "%(name)s")
- || CONTAINS(tracker:case-fold(
- tracker:unaccent(?match4)), "%(name)s")
- || CONTAINS(tracker:case-fold(?match4), "%(name)s")
- )
- %(location_filter)s
}
- LIMIT 50
""".replace('\n', ' ').strip() % {
+ "media_type": int(Grl.MediaType.AUDIO),
'location_filter': self._tracker_wrapper.location_filter(),
'name': term
}
@@ -868,31 +880,43 @@ class GrlTrackerWrapper(GObject.GObject):
self._window.notifications_popup.push_loading()
query = """
- SELECT DISTINCT
- rdf:type(nmm:musicAlbum(?song))
- tracker:id(nmm:musicAlbum(?song)) AS ?id
+ SELECT
+ ?type ?id
WHERE {
- ?song a nmm:MusicPiece .
- BIND(tracker:normalize(
- nie:title(nmm:musicAlbum(?song)), 'nfkd') AS ?match1) .
- BIND(tracker:normalize(
- nmm:artistName(nmm:performer(?song)), 'nfkd') AS ?match2) .
- BIND(tracker:normalize(nmm:composer(?song), 'nfkd') AS ?match4) .
- FILTER (
- CONTAINS(tracker:case-fold(
- tracker:unaccent(?match1)), "%(name)s")
- || CONTAINS(tracker:case-fold(?match1), "%(name)s")
- || CONTAINS(tracker:case-fold(
- tracker:unaccent(?match2)), "%(name)s")
- || CONTAINS(tracker:case-fold(?match2), "%(name)s")
- || CONTAINS(tracker:case-fold(
- tracker:unaccent(?match4)), "%(name)s")
- || CONTAINS(tracker:case-fold(?match4), "%(name)s")
- )
- %(location_filter)s
+ SERVICE <dbus:org.freedesktop.Tracker3.Miner.Files> {
+ GRAPH tracker:Audio {
+ SELECT DISTINCT
+ %(media_type)s AS ?type
+ nmm:musicAlbum(?song) AS ?id
+ WHERE {
+ ?song a nmm:MusicPiece .
+ BIND(tracker:normalize(
+ nie:title(nmm:musicAlbum(?song)), 'nfkd')
+ AS ?match1) .
+ BIND(tracker:normalize(
+ nmm:artistName(nmm:artist(?song)), 'nfkd')
+ AS ?match2) .
+ BIND(tracker:normalize(nmm:composer(?song), 'nfkd')
+ AS ?match4) .
+ FILTER (
+ CONTAINS(tracker:case-fold(
+ tracker:unaccent(?match1)), "%(name)s")
+ || CONTAINS(tracker:case-fold(?match1), "%(name)s")
+ || CONTAINS(tracker:case-fold(
+ tracker:unaccent(?match2)), "%(name)s")
+ || CONTAINS(tracker:case-fold(?match2), "%(name)s")
+ || CONTAINS(tracker:case-fold(
+ tracker:unaccent(?match4)), "%(name)s")
+ || CONTAINS(tracker:case-fold(?match4), "%(name)s")
+ )
+ %(location_filter)s
+ }
+ LIMIT 50
+ }
+ }
}
- LIMIT 50
""".replace('\n', ' ').strip() % {
+ "media_type": int(Grl.MediaType.CONTAINER),
'location_filter': self._tracker_wrapper.location_filter(),
'name': term
}
@@ -923,37 +947,48 @@ class GrlTrackerWrapper(GObject.GObject):
self._window.notifications_popup.push_loading()
query = """
- SELECT DISTINCT
- rdf:type(?song)
- tracker:id(?song) AS ?id
+ SELECT
+ ?type ?id
WHERE {
- ?song a nmm:MusicPiece .
- BIND(tracker:normalize(
- nie:title(nmm:musicAlbum(?song)), 'nfkd') AS ?match1) .
- BIND(tracker:normalize(
- nmm:artistName(nmm:performer(?song)), 'nfkd') AS ?match2) .
- BIND(tracker:normalize(
- nie:title(?song), 'nfkd') AS ?match3) .
- BIND(
- tracker:normalize(nmm:composer(?song), 'nfkd') AS ?match4) .
- FILTER (
- CONTAINS(tracker:case-fold(
- tracker:unaccent(?match1)), "%(name)s")
- || CONTAINS(tracker:case-fold(?match1), "%(name)s")
- || CONTAINS(tracker:case-fold(
- tracker:unaccent(?match2)), "%(name)s")
- || CONTAINS(tracker:case-fold(?match2), "%(name)s")
- || CONTAINS(tracker:case-fold(
- tracker:unaccent(?match3)), "%(name)s")
- || CONTAINS(tracker:case-fold(?match3), "%(name)s")
- || CONTAINS(tracker:case-fold(
- tracker:unaccent(?match4)), "%(name)s")
- || CONTAINS(tracker:case-fold(?match4), "%(name)s")
- )
- %(location_filter)s
+ SERVICE <dbus:org.freedesktop.Tracker3.Miner.Files> {
+ GRAPH tracker:Audio {
+ SELECT DISTINCT
+ %(media_type)s AS ?type
+ ?song AS ?id
+ WHERE {
+ ?song a nmm:MusicPiece .
+ BIND(tracker:normalize(
+ nie:title(nmm:musicAlbum(?song)), 'nfkd')
+ AS ?match1) .
+ BIND(tracker:normalize(
+ nmm:artistName(nmm:artist(?song)), 'nfkd')
+ AS ?match2) .
+ BIND(tracker:normalize(
+ nie:title(?song), 'nfkd') AS ?match3) .
+ BIND(tracker:normalize(nmm:composer(?song), 'nfkd')
+ AS ?match4) .
+ FILTER (
+ CONTAINS(tracker:case-fold(
+ tracker:unaccent(?match1)), "%(name)s")
+ || CONTAINS(tracker:case-fold(?match1), "%(name)s")
+ || CONTAINS(tracker:case-fold(
+ tracker:unaccent(?match2)), "%(name)s")
+ || CONTAINS(tracker:case-fold(?match2), "%(name)s")
+ || CONTAINS(tracker:case-fold(
+ tracker:unaccent(?match3)), "%(name)s")
+ || CONTAINS(tracker:case-fold(?match3), "%(name)s")
+ || CONTAINS(tracker:case-fold(
+ tracker:unaccent(?match4)), "%(name)s")
+ || CONTAINS(tracker:case-fold(?match4), "%(name)s")
+ )
+ %(location_filter)s
+ }
+ LIMIT 50
+ }
+ }
}
- LIMIT 50
""".replace('\n', ' ').strip() % {
+ "media_type": int(Grl.MediaType.AUDIO),
'location_filter': self._tracker_wrapper.location_filter(),
'name': term
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]