[gnome-music/wip/carlosg/tracker3: 19/39] grltrackerwrapper: Retrieve musicbrainz artist id for songs
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/carlosg/tracker3: 19/39] grltrackerwrapper: Retrieve musicbrainz artist id for songs
- Date: Mon, 3 Aug 2020 15:39:50 +0000 (UTC)
commit 43de24ea8f20bd57838a90157ff9541a75182ffc
Author: Jean Felder <jfelder src gnome org>
Date: Wed Jul 29 13:32:30 2020 +0200
grltrackerwrapper: Retrieve musicbrainz artist id for songs
gnomemusic/grilowrappers/grltrackerwrapper.py | 28 ++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index 309f94bf..29c59472 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -50,6 +50,7 @@ class GrlTrackerWrapper(GObject.GObject):
Grl.METADATA_KEY_DURATION,
Grl.METADATA_KEY_FAVOURITE,
Grl.METADATA_KEY_ID,
+ Grl.METADATA_KEY_MB_ARTIST_ID,
Grl.METADATA_KEY_MB_RECORDING_ID,
Grl.METADATA_KEY_MB_TRACK_ID,
Grl.METADATA_KEY_PLAY_COUNT,
@@ -337,7 +338,7 @@ class GrlTrackerWrapper(GObject.GObject):
query = """
SELECT
?type ?urn ?title ?id ?mbRecording ?mbTrack ?url
- ?artist ?album
+ ?artist ?mbArtist ?album
?albumArtist ?duration ?trackNumber
?albumDiscNumber ?creationDate
nie:usageCounter(?urn) AS ?playCount
@@ -355,6 +356,7 @@ class GrlTrackerWrapper(GObject.GObject):
tracker:referenceIdentifier(?track_id) AS ?mbTrack
nie:isStoredAs(?song) AS ?url
nmm:artistName(nmm:artist(?song)) AS ?artist
+ tracker:referenceIdentifier(?artist_id) AS ?mbArtist
nie:title(nmm:musicAlbum(?song)) AS ?album
?album_artist AS ?albumArtist
nfo:duration(?song) AS ?duration
@@ -380,6 +382,12 @@ class GrlTrackerWrapper(GObject.GObject):
?album nmm:albumArtist/
nmm:artistName ?album_artist .
}
+ OPTIONAL {
+ ?song nmm:artist ?artist .
+ ?artist tracker:hasExternalReference ?artist_id .
+ ?artist_id tracker:referenceSource
+ "https://musicbrainz.org/doc/Artist" .
+ }
FILTER ( ?song in ( %(media_ids)s ) )
%(location_filter)s
}
@@ -463,7 +471,7 @@ class GrlTrackerWrapper(GObject.GObject):
query = """
SELECT
?type ?urn ?title ?id ?mbRecording ?mbTrack ?url
- ?artist ?album
+ ?artist ?mbArtist ?album
?albumArtist ?duration ?trackNumber
?albumDiscNumber ?creationDate
nie:usageCounter(?urn) AS ?playCount
@@ -481,6 +489,7 @@ class GrlTrackerWrapper(GObject.GObject):
tracker:referenceIdentifier(?track_id) AS ?mbTrack
nie:isStoredAs(?song) AS ?url
nmm:artistName(nmm:artist(?song)) AS ?artist
+ tracker:referenceIdentifier(?artist_id) AS ?mbArtist
nie:title(nmm:musicAlbum(?song)) AS ?album
?album_artist AS ?albumArtist
nfo:duration(?song) AS ?duration
@@ -506,6 +515,12 @@ class GrlTrackerWrapper(GObject.GObject):
?album nmm:albumArtist/
nmm:artistName ?album_artist .
}
+ OPTIONAL {
+ ?song nmm:artist ?artist .
+ ?artist tracker:hasExternalReference ?artist_id .
+ ?artist_id tracker:referenceSource
+ "https://musicbrainz.org/doc/Artist" .
+ }
%(location_filter)s
}
ORDER BY ?title
@@ -794,7 +809,7 @@ class GrlTrackerWrapper(GObject.GObject):
query = """
SELECT
?type ?id ?mbRecording ?mbTrack ?url ?title
- ?artist ?album
+ ?artist ?mbArtist ?album
?albumArtist ?duration ?trackNumber ?albumDiscNumber
?creationDate
nie:usageCounter(?id) AS ?playCount
@@ -811,6 +826,7 @@ class GrlTrackerWrapper(GObject.GObject):
nie:isStoredAs(?song) AS ?url
nie:title(?song) AS ?title
nmm:artistName(nmm:artist(?song)) AS ?artist
+ tracker:referenceIdentifier(?artist_id) AS ?mbArtist
nie:title(nmm:musicAlbum(?song)) AS ?album
?album_artist AS ?albumArtist
nfo:duration(?song) AS ?duration
@@ -834,6 +850,12 @@ class GrlTrackerWrapper(GObject.GObject):
OPTIONAL { ?song nie:contentCreated ?date . }
OPTIONAL { ?album nmm:albumArtist/
nmm:artistName ?album_artist . }
+ OPTIONAL {
+ ?song nmm:artist ?artist .
+ ?artist tracker:hasExternalReference ?artist_id .
+ ?artist_id tracker:referenceSource
+ "https://musicbrainz.org/doc/Artist" .
+ }
FILTER (
?album = <%(album_id)s> &&
nmm:setNumber(nmm:musicAlbumDisc(?song)) =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]