[gnome-music/wip/jfelder/tracker3: 21/34] grltrackerwrapper: Port queries to resolve album from album/song URNs
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/tracker3: 21/34] grltrackerwrapper: Port queries to resolve album from album/song URNs
- Date: Fri, 28 Aug 2020 14:06:30 +0000 (UTC)
commit f37a733f0a19e7112d651a48a8474bb711aa5596
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun May 31 16:56:15 2020 +0200
grltrackerwrapper: Port queries to resolve album from album/song URNs
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 | 69 ++++++++++++++++-----------
1 file changed, 40 insertions(+), 29 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index 57dafa4c..52cc2cc1 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -1022,42 +1022,53 @@ class GrlTrackerWrapper(GObject.GObject):
# only that key for retrieval.
if song:
- filter_clause = "tracker:id(?song) = {}".format(str(media_id))
+ filter_clause = "?song = <{}>".format(str(media_id))
else:
- filter_clause = "tracker:id(?album) = {}".format(str(media_id))
+ filter_clause = "?album = <{}>".format(str(media_id))
query = """
- SELECT DISTINCT
- rdf:type(?album)
- tracker:id(?album) AS ?id
- tracker:referenceIdentifier(?release_group_id)
- AS ?mb_release_group_id
- tracker:referenceIdentifier(?release_id) AS ?mb_release_id
- tracker:coalesce(nmm:artistName(?album_artist),
- nmm:artistName(?song_artist)) AS ?artist
- nie:title(?album) AS ?album
+ SELECT
+ ?type ?id ?mbReleaseGroup ?mbRelease ?artist ?album
WHERE {
- ?album a nmm:MusicAlbum .
- ?song a nmm:MusicPiece ;
- nmm:musicAlbum ?album ;
- nmm:performer ?song_artist .
- OPTIONAL {
- ?album tracker:hasExternalReference ?release_group_id .
- ?release_group_id tracker:referenceSource
- "https://musicbrainz.org/doc/Release_Group" .
- }
- OPTIONAL {
- ?album tracker:hasExternalReference ?release_id .
- ?release_id tracker:referenceSource
- "https://musicbrainz.org/doc/Release" .
+ SERVICE <dbus:org.freedesktop.Tracker3.Miner.Files> {
+ GRAPH tracker:Audio {
+ SELECT DISTINCT
+ %(media_type)s AS ?type
+ ?album AS ?id
+ tracker:referenceIdentifier(?release_group_id)
+ AS ?mbReleaseGroup
+ tracker:referenceIdentifier(?release_id) AS ?mbRelease
+ tracker:coalesce(nmm:artistName(?album_artist),
+ nmm:artistName(?song_artist))
+ AS ?artist
+ nie:title(?album) AS ?album
+ WHERE {
+ ?album a nmm:MusicAlbum .
+ ?song a nmm:MusicPiece ;
+ nmm:musicAlbum ?album ;
+ nmm:artist ?song_artist .
+ OPTIONAL {
+ ?album tracker:hasExternalReference
+ ?release_group_id .
+ ?release_group_id tracker:referenceSource
+ "https://musicbrainz.org/doc/Release_Group" .
+ }
+ OPTIONAL {
+ ?album tracker:hasExternalReference ?release_id .
+ ?release_id tracker:referenceSource
+ "https://musicbrainz.org/doc/Release" .
+ }
+ OPTIONAL { ?album nmm:albumArtist ?album_artist . }
+ FILTER (
+ %(filter_clause)s
+ )
+ %(location_filter)s
+ }
+ }
}
- OPTIONAL { ?album nmm:albumArtist ?album_artist . }
- FILTER (
- %(filter_clause)s
- )
- %(location_filter)s
}
""".replace("\n", " ").strip() % {
+ "media_type": int(Grl.MediaType.CONTAINER),
"filter_clause": filter_clause,
"location_filter": self._tracker_wrapper.location_filter()
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]