[gnome-music/wip/jfelder/tracker3-rebased: 30/49] grltrackerwrapper: Retrieve musicbrainz release id for songs




commit d1b6e41f4e3686c80c30c8a33bf0b5d0b142b95e
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 | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index 1d868308..7dc94ba0 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -52,6 +52,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_THUMBNAIL,
@@ -338,7 +339,7 @@ class GrlTrackerWrapper(GObject.GObject):
         query = """
         SELECT
             ?type ?urn ?title ?id ?mbRecording ?mbTrack ?url
-            ?artist ?mbArtist ?album
+            ?artist ?mbArtist ?album ?mbRelease
             ?albumArtist ?duration ?trackNumber
             ?albumDiscNumber ?creationDate
             nie:usageCounter(?urn) AS ?playCount
@@ -358,6 +359,7 @@ class GrlTrackerWrapper(GObject.GObject):
                         nmm:artistName(nmm:performer(?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
@@ -382,6 +384,12 @@ class GrlTrackerWrapper(GObject.GObject):
                             ?album nmm:albumArtist/
                                    nmm:artistName ?album_artist .
                         }
+                        OPTIONAL {
+                            ?song nmm:musicAlbum ?album .
+                            ?album tracker:hasExternalReference ?release_id .
+                            ?release_id tracker:referenceSource
+                                "https://musicbrainz.org/doc/Release"; .
+                        }
                         OPTIONAL {
                             ?song nmm:performer ?artist .
                             ?artist tracker:hasExternalReference ?artist_id .
@@ -471,7 +479,7 @@ class GrlTrackerWrapper(GObject.GObject):
         query = """
         SELECT
             ?type ?urn ?title ?id ?mbRecording ?mbTrack ?url
-            ?artist ?mbArtist ?album
+            ?artist ?mbArtist ?album ?mbRelease
             ?albumArtist ?duration ?trackNumber
             ?albumDiscNumber ?creationDate
             nie:usageCounter(?urn) AS ?playCount
@@ -491,6 +499,7 @@ class GrlTrackerWrapper(GObject.GObject):
                         nmm:artistName(nmm:performer(?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
@@ -515,6 +524,12 @@ class GrlTrackerWrapper(GObject.GObject):
                             ?album nmm:albumArtist/
                                    nmm:artistName ?album_artist .
                         }
+                        OPTIONAL {
+                            ?song nmm:musicAlbum ?album .
+                            ?album tracker:hasExternalReference ?release_id .
+                            ?release_id tracker:referenceSource
+                                "https://musicbrainz.org/doc/Release"; .
+                        }
                         OPTIONAL {
                             ?song nmm:performer ?artist .
                             ?artist tracker:hasExternalReference ?artist_id .
@@ -809,7 +824,7 @@ class GrlTrackerWrapper(GObject.GObject):
         query = """
         SELECT
             ?type ?id ?mbRecording ?mbTrack ?url ?title
-            ?artist ?mbArtist ?album
+            ?artist ?mbArtist ?album ?mbRelease
             ?albumArtist ?duration ?trackNumber ?albumDiscNumber
             ?creationDate
             nie:usageCounter(?id) AS ?playCount
@@ -828,6 +843,7 @@ class GrlTrackerWrapper(GObject.GObject):
                         nmm:artistName(nmm:performer(?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
@@ -850,6 +866,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:performer ?artist .
                             ?artist tracker:hasExternalReference ?artist_id .


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