[gnome-music/wip/mschraal/tageditor-13feb2020: 11/25] grltrackerwrapper: Retrieve musicbrainz release group id for songs



commit a8fcbf11da15a5e0199ceafbc9eec6e546271c04
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 16c83017..caf06618 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,
@@ -313,6 +314,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
@@ -343,6 +346,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 .
@@ -426,6 +435,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
@@ -456,6 +467,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 .
@@ -710,6 +727,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
@@ -737,6 +756,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]