[gnome-music/wip/mschraal/flac-cue: 6/8] grltrackerwrapper: Add support for flac+cue



commit adb480b32e12ac920ec15fb78541d204428a6883
Author: Marinus Schraal <mschraal gnome org>
Date:   Tue Nov 5 14:15:56 2019 +0100

    grltrackerwrapper: Add support for flac+cue

 gnomemusic/coresong.py                        |  2 +
 gnomemusic/grilowrappers/grltrackerwrapper.py | 60 +++++++++++++++++----------
 gnomemusic/trackerwrapper.py                  |  2 +-
 3 files changed, 42 insertions(+), 22 deletions(-)
---
diff --git a/gnomemusic/coresong.py b/gnomemusic/coresong.py
index c2befcb6..c6da534b 100644
--- a/gnomemusic/coresong.py
+++ b/gnomemusic/coresong.py
@@ -42,6 +42,7 @@ class CoreSong(GObject.GObject):
     media = GObject.Property(type=Grl.Media)
     grlid = GObject.Property(type=str, default=None)
     play_count = GObject.Property(type=int)
+    start_time = GObject.Property(type=float)
     state = GObject.Property()  # FIXME: How to set an IntEnum type?
     title = GObject.Property(type=str)
     track_number = GObject.Property(type=int)
@@ -120,6 +121,7 @@ class CoreSong(GObject.GObject):
         self.props.favorite = media.get_favourite()
         self.props.play_count = media.get_play_count()
         self.props.title = utils.get_media_title(media)
+        self.props.start_time = media.get_start_time()
         self.props.track_number = media.get_track_number()
         self.props.url = media.get_url()
 
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index ceb8242e..a4b9cc9d 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -49,6 +49,7 @@ class GrlTrackerWrapper(GObject.GObject):
         Grl.METADATA_KEY_FAVOURITE,
         Grl.METADATA_KEY_ID,
         Grl.METADATA_KEY_PLAY_COUNT,
+        Grl.METADATA_KEY_START_TIME,
         Grl.METADATA_KEY_THUMBNAIL,
         Grl.METADATA_KEY_TITLE,
         Grl.METADATA_KEY_TRACK_NUMBER,
@@ -162,13 +163,14 @@ class GrlTrackerWrapper(GObject.GObject):
             ?composer AS ?composer
             ?album_artist AS ?album_artist
             nmm:artistName(?performer) AS ?artist
-            nie:url(?song) AS ?url
+            nie:url(?file) AS ?url
             YEAR(MAX(nie:contentCreated(?song))) AS ?creation_date
         WHERE {
             ?album a nmm:MusicAlbum .
             ?song a nmm:MusicPiece ;
                     nmm:musicAlbum ?album ;
-                    nmm:performer ?performer .
+                    nmm:performer ?performer ;
+                    nie:isStoredAs ?file .
             OPTIONAL { ?song nmm:composer/nmm:artistName ?composer . }
             OPTIONAL { ?album nmm:albumArtist/nmm:artistName ?album_artist . }
             %(location_filter)s
@@ -223,7 +225,8 @@ class GrlTrackerWrapper(GObject.GObject):
             ?artist_class a nmm:Artist .
             ?song a nmm:MusicPiece;
                     nmm:musicAlbum ?album;
-                    nmm:performer ?artist_class .
+                    nmm:performer ?artist_class ;
+                    nie:isStoredAs ?file .
             %(location_filter)s
         } GROUP BY ?artist_class
         """.replace('\n', ' ').strip() % {
@@ -290,7 +293,7 @@ class GrlTrackerWrapper(GObject.GObject):
             nie:title(?song) AS ?title
             tracker:id(?song) AS ?id
             ?song
-            nie:url(?song) AS ?url
+            nie:url(?file) AS ?url
             nie:title(?song) AS ?title
             nmm:artistName(nmm:performer(?song)) AS ?artist
             nie:title(nmm:musicAlbum(?song)) AS ?album
@@ -298,9 +301,11 @@ class GrlTrackerWrapper(GObject.GObject):
             nie:usageCounter(?song) AS ?play_count
             nmm:trackNumber(?song) AS ?track_number
             nmm:setNumber(nmm:musicAlbumDisc(?song)) AS ?album_disc_number
+            nfo:audioOffset(?song) AS ?start_time
             ?tag AS ?favourite
         WHERE {
-            ?song a nmm:MusicPiece .
+            ?song a nmm:MusicPiece ;
+                    nie:isStoredAs ?file .
             OPTIONAL {
                 ?song nao:hasTag ?tag .
                 FILTER (?tag = nao:predefined-tag-favorite)
@@ -363,7 +368,7 @@ class GrlTrackerWrapper(GObject.GObject):
             nie:title(?song) AS ?title
             tracker:id(?song) AS ?id
             ?song
-            nie:url(?song) AS ?url
+            nie:url(?file) AS ?url
             nie:title(?song) AS ?title
             nmm:artistName(nmm:performer(?song)) AS ?artist
             nie:title(nmm:musicAlbum(?song)) AS ?album
@@ -371,9 +376,11 @@ class GrlTrackerWrapper(GObject.GObject):
             nie:usageCounter(?song) AS ?play_count
             nmm:trackNumber(?song) AS ?track_number
             nmm:setNumber(nmm:musicAlbumDisc(?song)) AS ?album_disc_number
+            nfo:audioOffset(?song) AS ?start_time
             ?tag AS ?favourite
         WHERE {
-            ?song a nmm:MusicPiece .
+            ?song a nmm:MusicPiece ;
+                    nie:isStoredAs ?file .
             OPTIONAL {
                 ?song nao:hasTag ?tag .
                 FILTER (?tag = nao:predefined-tag-favorite)
@@ -413,14 +420,15 @@ class GrlTrackerWrapper(GObject.GObject):
             ?composer AS ?composer
             ?album_artist AS ?album_artist
             nmm:artistName(?performer) AS ?artist
-            nie:url(?song) AS ?url
+            nie:url(?file) AS ?url
             YEAR(MAX(nie:contentCreated(?song))) AS ?creation_date
         WHERE
         {
             ?album a nmm:MusicAlbum .
             ?song a nmm:MusicPiece ;
                     nmm:musicAlbum ?album ;
-                    nmm:performer ?performer .
+                    nmm:performer ?performer;
+                    nie:isStoredAs ?file .
             OPTIONAL { ?song nmm:composer/nmm:artistName ?composer . }
             OPTIONAL { ?album nmm:albumArtist/nmm:artistName ?album_artist . }
             %(location_filter)s
@@ -462,7 +470,8 @@ class GrlTrackerWrapper(GObject.GObject):
             ?artist a nmm:Artist .
             ?song a nmm:MusicPiece;
                     nmm:musicAlbum ?album;
-                    nmm:performer ?artist .
+                    nmm:performer ?artist ;
+                    nie:isStoredAs ?file .
             %(location_filter)s
         }
         GROUP BY ?artist
@@ -494,9 +503,10 @@ class GrlTrackerWrapper(GObject.GObject):
         WHERE {
             ?album a nmm:MusicAlbum .
             OPTIONAL { ?album  nmm:albumArtist ?album_artist . }
-            ?song a nmm:MusicPiece;
-                    nmm:musicAlbum ?album;
-                    nmm:performer ?artist .
+            ?song a nmm:MusicPiece ;
+                    nmm:musicAlbum ?album ;
+                    nmm:performer ?artist ;
+                    nie:isStoredAs ?file .
             FILTER ( tracker:id(?album_artist) = %(artist_id)s
                      || tracker:id(?artist) = %(artist_id)s )
             %(location_filter)s
@@ -550,7 +560,8 @@ class GrlTrackerWrapper(GObject.GObject):
             nmm:setNumber(nmm:musicAlbumDisc(?song)) as ?album_disc_number
         WHERE {
             ?song a nmm:MusicPiece;
-                    nmm:musicAlbum ?album .
+                    nmm:musicAlbum ?album ;
+                    nie:isStoredAs ?file .
             FILTER ( tracker:id(?album) = %(album_id)s )
             %(location_filter)s
         }
@@ -595,18 +606,20 @@ class GrlTrackerWrapper(GObject.GObject):
             rdf:type(?song)
             ?song AS ?tracker_urn
             tracker:id(?song) AS ?id
-            nie:url(?song) AS ?url
+            nie:url(?file) AS ?url
             nie:title(?song) AS ?title
             nmm:artistName(nmm:performer(?song)) AS ?artist
             nie:title(nmm:musicAlbum(?song)) AS ?album
             nfo:duration(?song) AS ?duration
             nmm:trackNumber(?song) AS ?track_number
             nmm:setNumber(nmm:musicAlbumDisc(?song)) AS ?album_disc_number
+            nfo:audioOffset(?song) AS ?start_time
             ?tag AS ?favourite
             nie:usageCounter(?song) AS ?play_count
         WHERE {
             ?song a nmm:MusicPiece ;
-                    nmm:musicAlbum ?album .
+                    nmm:musicAlbum ?album ;
+                    nie:isStoredAs ?file .
             OPTIONAL { ?song nao:hasTag ?tag .
                        FILTER (?tag = nao:predefined-tag-favorite) } .
             FILTER ( tracker:id(?album) = %(album_id)s
@@ -644,7 +657,8 @@ class GrlTrackerWrapper(GObject.GObject):
         WHERE {
             ?song a nmm:MusicPiece ;
                     nmm:musicAlbum ?album ;
-                    nmm:performer ?artist .
+                    nmm:performer ?artist ;
+                    nie:isStoredAs ?file .
             BIND(tracker:normalize(
                 nmm:artistName(nmm:albumArtist(?album)), 'nfkd') AS ?match1) .
             BIND(tracker:normalize(
@@ -699,7 +713,8 @@ class GrlTrackerWrapper(GObject.GObject):
             rdf:type(nmm:musicAlbum(?song))
             tracker:id(nmm:musicAlbum(?song)) AS ?id
         WHERE {
-            ?song a nmm:MusicPiece .
+            ?song a nmm:MusicPiece ;
+                    nie:isStoredAs ?file .
             BIND(tracker:normalize(
                 nie:title(nmm:musicAlbum(?song)), 'nfkd') AS ?match1) .
             BIND(tracker:normalize(
@@ -754,7 +769,8 @@ class GrlTrackerWrapper(GObject.GObject):
             rdf:type(?song)
             tracker:id(?song) AS ?id
         WHERE {
-            ?song a nmm:MusicPiece .
+            ?song a nmm:MusicPiece ;
+                    nie:isStoredAs ?file .
             BIND(tracker:normalize(
                 nie:title(nmm:musicAlbum(?song)), 'nfkd') AS ?match1) .
             BIND(tracker:normalize(
@@ -844,7 +860,8 @@ class GrlTrackerWrapper(GObject.GObject):
             ?album a nmm:MusicAlbum .
             ?song a nmm:MusicPiece ;
                     nmm:musicAlbum ?album ;
-                    nmm:performer ?song_artist .
+                    nmm:performer ?song_artist ;
+                    nie:isStoredAs ?file .
             OPTIONAL {
                 ?album tracker:hasExternalReference ?release_group_id .
                 ?release_group_id tracker:referenceSource
@@ -883,7 +900,8 @@ class GrlTrackerWrapper(GObject.GObject):
         WHERE {
             ?song a nmm:MusicPiece ;
                     nmm:musicAlbum ?album ;
-                    nmm:performer ?song_artist .
+                    nmm:performer ?song_artist ;
+                    nie:isStoredAs ?file .
             OPTIONAL {
                 ?album tracker:hasExternalReference ?release_group_id .
                 ?release_group_id tracker:referenceSource
diff --git a/gnomemusic/trackerwrapper.py b/gnomemusic/trackerwrapper.py
index d6fbb463..7bfcc1f7 100644
--- a/gnomemusic/trackerwrapper.py
+++ b/gnomemusic/trackerwrapper.py
@@ -105,6 +105,6 @@ class TrackerWrapper(GObject.GObject):
         music_dir = Tracker.sparql_escape_string(
             GLib.filename_to_uri(music_dir))
 
-        query = "FILTER (STRSTARTS(nie:url(?song), '{}/'))".format(music_dir)
+        query = "FILTER (STRSTARTS(nie:url(?file), '{}/'))".format(music_dir)
 
         return query


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