[gnome-music/wip/mschraal/tracker3: 9/19] 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/mschraal/tracker3: 9/19] grltrackerwrapper: Port queries to resolve album from album/song URNs
- Date: Mon, 24 Aug 2020 14:00:59 +0000 (UTC)
commit 69afcfdca72325686280aad09f28cac99f65ae40
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 | 140 +++++++++++++++-----------
1 file changed, 81 insertions(+), 59 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index 661256a2..f769257e 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -1165,39 +1165,50 @@ class GrlTrackerWrapper(GObject.GObject):
# the artist key, since Grilo coverart plugins use
# only that key for retrieval.
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: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" .
+ }
+ OPTIONAL { ?album nmm:albumArtist ?album_artist . }
+ FILTER (
+ ?album = <%(album_id)s>
+ )
+ %(location_filter)s
+ }
+ }
}
- OPTIONAL { ?album nmm:albumArtist ?album_artist . }
- FILTER (
- tracker:id(?album) = %(album_id)s
- )
- %(location_filter)s
}
""".replace("\n", " ").strip() % {
- 'album_id': album_id,
- 'location_filter': self._tracker_wrapper.location_filter()
+ 'media_type': int(Grl.MediaType.CONTAINER),
+ 'album_id': album_id,
+ 'location_filter': self._tracker_wrapper.location_filter()
}
return query
@@ -1205,40 +1216,51 @@ class GrlTrackerWrapper(GObject.GObject):
def _get_album_for_song_id(self, song_id):
# See get_album_for_album_id comment.
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 {
- ?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 {
+ ?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" .
+ }
+ OPTIONAL { ?album nmm:albumArtist ?album_artist . }
+ FILTER (
+ ?song = <%(song_id)s>
+ )
+ FILTER (
+ NOT EXISTS { ?song a nmm:Video }
+ && NOT EXISTS { ?song a nmm:Playlist }
+ )
+ %(location_filter)s
+ }
+ }
}
- OPTIONAL { ?album nmm:albumArtist ?album_artist . }
- FILTER (
- tracker:id(?song) = %(song_id)s
- )
- FILTER (
- NOT EXISTS { ?song a nmm:Video }
- && NOT EXISTS { ?song a nmm:Playlist }
- )
- %(location_filter)s
}
""".replace("\n", " ").strip() % {
+ 'media_type': int(Grl.MediaType.CONTAINER),
'location_filter': self._tracker_wrapper.location_filter(),
'song_id': song_id
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]