[gnome-music/wip/jfelder/tracker3-rebased: 17/39] grltrackerwrapper: Retrieve musicbrainz track id for songs




commit ae30eaffcb8bf078a17802f5a3c85d15beb12f0c
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Jul 29 12:51:12 2020 +0200

    grltrackerwrapper: Retrieve musicbrainz track id for songs

 gnomemusic/grilowrappers/grltrackerwrapper.py | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index 91a0a78e..66e3be81 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -51,6 +51,7 @@ class GrlTrackerWrapper(GObject.GObject):
         Grl.METADATA_KEY_FAVOURITE,
         Grl.METADATA_KEY_ID,
         Grl.METADATA_KEY_MB_RECORDING_ID,
+        Grl.METADATA_KEY_MB_TRACK_ID,
         Grl.METADATA_KEY_PLAY_COUNT,
         Grl.METADATA_KEY_THUMBNAIL,
         Grl.METADATA_KEY_TITLE,
@@ -335,7 +336,7 @@ class GrlTrackerWrapper(GObject.GObject):
 
         query = """
         SELECT
-            ?type ?urn ?title ?id ?mbRecording ?url
+            ?type ?urn ?title ?id ?mbRecording ?mbTrack ?url
             ?artist ?album
             ?duration ?trackNumber
             ?albumDiscNumber ?creationDate
@@ -351,6 +352,7 @@ class GrlTrackerWrapper(GObject.GObject):
                         ?song AS ?id
                         tracker:referenceIdentifier(?recording_id)
                             AS ?mbRecording
+                        tracker:referenceIdentifier(?track_id) AS ?mbTrack
                         nie:isStoredAs(?song) AS ?url
                         nmm:artistName(nmm:performer(?song)) AS ?artist
                         nie:title(nmm:musicAlbum(?song)) AS ?album
@@ -366,6 +368,11 @@ class GrlTrackerWrapper(GObject.GObject):
                             ?recording_id tracker:referenceSource
                                 "https://musicbrainz.org/doc/Recording"; .
                         }
+                        OPTIONAL {
+                            ?song tracker:hasExternalReference ?track_id .
+                            ?track_id tracker:referenceSource
+                                "https://musicbrainz.org/doc/Track"; .
+                        }
                         OPTIONAL { ?song nie:contentCreated ?date . }
                         FILTER ( ?song in ( %(media_ids)s ) )
                         %(location_filter)s
@@ -449,7 +456,7 @@ class GrlTrackerWrapper(GObject.GObject):
 
         query = """
         SELECT
-            ?type ?urn ?title ?id ?mbRecording ?url
+            ?type ?urn ?title ?id ?mbRecording ?mbTrack ?url
             ?artist ?album
             ?duration ?trackNumber
             ?albumDiscNumber ?creationDate
@@ -465,6 +472,7 @@ class GrlTrackerWrapper(GObject.GObject):
                         ?song AS ?id
                         tracker:referenceIdentifier(?recording_id)
                             AS ?mbRecording
+                        tracker:referenceIdentifier(?track_id) AS ?mbTrack
                         nie:isStoredAs(?song) AS ?url
                         nmm:artistName(nmm:performer(?song)) AS ?artist
                         nie:title(nmm:musicAlbum(?song)) AS ?album
@@ -480,6 +488,11 @@ class GrlTrackerWrapper(GObject.GObject):
                             ?recording_id tracker:referenceSource
                                 "https://musicbrainz.org/doc/Recording"; .
                         }
+                        OPTIONAL {
+                            ?song tracker:hasExternalReference ?track_id .
+                            ?track_id tracker:referenceSource
+                                "https://musicbrainz.org/doc/Track"; .
+                        }
                         OPTIONAL { ?song nie:contentCreated ?date . }
                         %(location_filter)s
                     }
@@ -768,7 +781,7 @@ class GrlTrackerWrapper(GObject.GObject):
 
         query = """
         SELECT
-            ?type ?id ?mbRecording ?url ?title
+            ?type ?id ?mbRecording ?mbTrack ?url ?title
             ?artist ?album
             ?duration ?trackNumber ?albumDiscNumber
             ?creationDate
@@ -782,6 +795,7 @@ class GrlTrackerWrapper(GObject.GObject):
                         ?song AS ?id
                         tracker:referenceIdentifier(?recording_id)
                             AS ?mbRecording
+                        tracker:referenceIdentifier(?track_id) AS ?mbTrack
                         nie:isStoredAs(?song) AS ?url
                         nie:title(?song) AS ?title
                         nmm:artistName(nmm:performer(?song)) AS ?artist
@@ -799,6 +813,11 @@ class GrlTrackerWrapper(GObject.GObject):
                             ?recording_id tracker:referenceSource
                                 "https://musicbrainz.org/doc/Recording"; .
                         }
+                        OPTIONAL {
+                            ?song tracker:hasExternalReference ?track_id .
+                            ?track_id tracker:referenceSource
+                                "https://musicbrainz.org/doc/Track"; .
+                        }
                         OPTIONAL { ?song nie:contentCreated ?date . }
                         FILTER (
                             ?album = <%(album_id)s> &&


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