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




commit 05261d3351f78007cba8271e12f4344e8c6141e3
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 3ce5f8b56..403432b02 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -71,6 +71,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,
@@ -428,7 +429,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
@@ -448,6 +449,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
@@ -466,6 +468,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 .
@@ -837,7 +845,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
@@ -856,6 +864,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
@@ -878,6 +887,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]