[gnome-music/wip/jfelder/songeditor-gtk4: 58/76] grltrackerwrapper: Retrieve musicbrainz release id for songs




commit 38f96e8bda2f2b034495a8d6210f267c296a7ac2
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Jul 29 13:52:18 2020 +0200

    grltrackerwrapper: Retrieve musicbrainz release id for songs

 gnomemusic/grilowrappers/grltrackerwrapper.py | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index 7459f6f0f..7cb32935e 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -72,6 +72,7 @@ class GrlTrackerWrapper(GObject.GObject):
         Grl.METADATA_KEY_ID,
         Grl.METADATA_KEY_MB_ARTIST_ID,
         Grl.METADATA_KEY_MB_RECORDING_ID,
+        Grl.METADATA_KEY_MB_RELEASE_ID,
         Grl.METADATA_KEY_MB_TRACK_ID,
         Grl.METADATA_KEY_PLAY_COUNT,
         Grl.METADATA_KEY_TITLE,
@@ -429,7 +430,7 @@ class GrlTrackerWrapper(GObject.GObject):
         query = " ".join(f"""
         SELECT
             ?type ?urn ?title ?id ?mbRecording ?mbTrack ?url
-            ?artist ?mbArtist ?album
+            ?artist ?mbArtist ?album ?mbRelease
             ?albumArtist ?duration ?trackNumber
             ?albumDiscNumber ?publicationDate
             nie:usageCounter(?urn) AS ?playCount
@@ -449,6 +450,7 @@ class GrlTrackerWrapper(GObject.GObject):
                         nmm:artistName(nmm:artist(?song)) AS ?artist
                         tracker:referenceIdentifier(?artist_id) AS ?mbArtist
                         nie:title(nmm:musicAlbum(?song)) AS ?album
+                        tracker:referenceIdentifier(?release_id) AS ?mbRelease
                         ?album_artist AS ?albumArtist
                         nfo:duration(?song) AS ?duration
                         nmm:trackNumber(?song) AS ?trackNumber
@@ -467,6 +469,12 @@ class GrlTrackerWrapper(GObject.GObject):
                             ?track_id tracker:referenceSource
                                 "https://musicbrainz.org/doc/Track"; .
                         }}
+                        OPTIONAL {{
+                            ?song nmm:musicAlbum ?album .
+                            ?album tracker:hasExternalReference ?release_id .
+                            ?release_id tracker:referenceSource
+                                "https://musicbrainz.org/doc/Release"; .
+                        }}
                         OPTIONAL {{
                             ?song nmm:artist ?artist .
                             ?artist tracker:hasExternalReference ?artist_id .
@@ -838,7 +846,7 @@ class GrlTrackerWrapper(GObject.GObject):
         query = """
         SELECT
             ?type ?id ?mbRecording ?mbTrack ?url ?title
-            ?artist ?mbArtist ?album
+            ?artist ?mbArtist ?album ?mbRelease
             ?albumArtist ?duration ?trackNumber ?albumDiscNumber
             ?publicationDate
             nie:usageCounter(?id) AS ?playCount
@@ -857,6 +865,7 @@ class GrlTrackerWrapper(GObject.GObject):
                         nmm:artistName(nmm:artist(?song)) AS ?artist
                         tracker:referenceIdentifier(?artist_id) AS ?mbArtist
                         nie:title(nmm:musicAlbum(?song)) AS ?album
+                        tracker:referenceIdentifier(?release_id) AS ?mbRelease
                         ?album_artist AS ?albumArtist
                         nfo:duration(?song) AS ?duration
                         nmm:trackNumber(?song) AS ?trackNumber
@@ -879,6 +888,11 @@ class GrlTrackerWrapper(GObject.GObject):
                         OPTIONAL { ?song nie:contentCreated ?date . }
                         OPTIONAL { ?album nmm:albumArtist/
                                           nmm:artistName ?album_artist . }
+                        OPTIONAL {
+                            ?album tracker:hasExternalReference ?release_id .
+                            ?release_id tracker:referenceSource
+                                "https://musicbrainz.org/doc/Release"; .
+                        }
                         OPTIONAL {
                             ?song nmm:artist ?artist .
                             ?artist tracker:hasExternalReference ?artist_id .


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]