[gnome-music/wip/carlosg/tracker3: 28/68] grltrackerwrapper: Retrieve musicbrainz release group id for songs



commit 1f2432ec77a9a205f63bb981e20d5423019c05d4
Author: Jean Felder <jfelder src gnome org>
Date:   Fri Jan 24 02:47:44 2020 +0100

    grltrackerwrapper: Retrieve musicbrainz release group id for songs

 gnomemusic/grilowrappers/grltrackerwrapper.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
---
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index 03e3ccc3..8b2d7427 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -52,6 +52,7 @@ class GrlTrackerWrapper(GObject.GObject):
         Grl.METADATA_KEY_MB_ARTIST_ID,
         Grl.METADATA_KEY_MB_RECORDING_ID,
         Grl.METADATA_KEY_MB_RELEASE_ID,
+        Grl.METADATA_KEY_MB_RELEASE_GROUP_ID,
         Grl.METADATA_KEY_MB_TRACK_ID,
         Grl.METADATA_KEY_PLAY_COUNT,
         Grl.METADATA_KEY_THUMBNAIL,
@@ -325,6 +326,8 @@ class GrlTrackerWrapper(GObject.GObject):
             tracker:referenceIdentifier(?artist_id) AS ?mb_artist_id
             nie:title(nmm:musicAlbum(?song)) AS ?album
             tracker:referenceIdentifier(?release_id) AS ?mb_release_id
+            tracker:referenceIdentifier(?release_group_id)
+                AS ?mb_release_group_id
             ?album_artist AS ?album_artist
             nfo:duration(?song) AS ?duration
             nie:usageCounter(?song) AS ?play_count
@@ -355,6 +358,12 @@ class GrlTrackerWrapper(GObject.GObject):
                 ?release_id tracker:referenceSource
                     "https://musicbrainz.org/doc/Release"; .
             }
+            OPTIONAL {
+                ?song nmm:musicAlbum ?album .
+                ?album tracker:hasExternalReference ?release_group_id .
+                ?release_group_id tracker:referenceSource
+                    "https://musicbrainz.org/doc/Release_Group"; .
+            }
             OPTIONAL {
                 ?song nmm:performer ?artist .
                 ?artist tracker:hasExternalReference ?artist_id .
@@ -451,6 +460,8 @@ class GrlTrackerWrapper(GObject.GObject):
             tracker:referenceIdentifier(?artist_id) AS ?mb_artist_id
             nie:title(nmm:musicAlbum(?song)) AS ?album
             tracker:referenceIdentifier(?release_id) AS ?mb_release_id
+            tracker:referenceIdentifier(?release_group_id)
+                AS ?mb_release_group_id
             ?album_artist AS ?album_artist
             nfo:duration(?song) AS ?duration
             nie:usageCounter(?song) AS ?play_count
@@ -481,6 +492,12 @@ class GrlTrackerWrapper(GObject.GObject):
                 ?release_id tracker:referenceSource
                     "https://musicbrainz.org/doc/Release"; .
             }
+            OPTIONAL {
+                ?song nmm:musicAlbum ?album .
+                ?album tracker:hasExternalReference ?release_group_id .
+                ?release_group_id tracker:referenceSource
+                    "https://musicbrainz.org/doc/Release_Group"; .
+            }
             OPTIONAL {
                 ?song nmm:performer ?artist .
                 ?artist tracker:hasExternalReference ?artist_id .
@@ -736,6 +753,8 @@ class GrlTrackerWrapper(GObject.GObject):
             tracker:referenceIdentifier(?artist_id) AS ?mb_artist_id
             nie:title(nmm:musicAlbum(?song)) AS ?album
             tracker:referenceIdentifier(?release_id) AS ?mb_release_id
+            tracker:referenceIdentifier(?release_group_id)
+                AS ?mb_release_group_id
             ?album_artist AS ?album_artist
             nfo:duration(?song) AS ?duration
             nmm:trackNumber(?song) AS ?track_number
@@ -763,6 +782,11 @@ class GrlTrackerWrapper(GObject.GObject):
                 ?release_id tracker:referenceSource
                     "https://musicbrainz.org/doc/Release"; .
             }
+            OPTIONAL {
+                ?album tracker:hasExternalReference ?release_group_id .
+                ?release_group_id tracker:referenceSource
+                    "https://musicbrainz.org/doc/Release_Group"; .
+            }
             OPTIONAL {
                 ?song nmm:performer ?artist .
                 ?artist tracker:hasExternalReference ?artist_id .


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