[gnome-music/wip/jfelder/playlist-add-songs-fix: 15/17] grltrackerplaylists: Fix update playlist query when adding songs




commit 49737ba348680f0195255f1f12520d29f06481fe
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Feb 24 16:29:04 2021 +0100

    grltrackerplaylists: Fix update playlist query when adding songs
    
    When songs are added to a user playlist, a query is performed to
    update the playlist and display the new songs. However, this query
    does not work because the url parameter is not correctly selected.
    
    This commit fixes the query by adding the following elements:
    - select url in the tracker:Audio graph
    - move the filter of the song id in tracker:Audio graph selection to
      ensure that the resource is available
    - add a playlist id filter to prevent selection of the same song
      several times if it is already part of an other playlist
    
    Closes: https://gitlab.gnome.org/GNOME/gnome-music/-/issues/445

 gnomemusic/grilowrappers/grltrackerplaylists.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerplaylists.py b/gnomemusic/grilowrappers/grltrackerplaylists.py
index d348597c5..d4a2f0de9 100644
--- a/gnomemusic/grilowrappers/grltrackerplaylists.py
+++ b/gnomemusic/grilowrappers/grltrackerplaylists.py
@@ -605,6 +605,7 @@ class Playlist(GObject.GObject):
                 return
 
             media_id = coresong.props.media.get_id()
+            pl_id = self.props.pl_id
             miner_fs_busname = self._tracker_wrapper.props.miner_fs_busname
             query = """
             SELECT
@@ -632,10 +633,14 @@ class Playlist(GObject.GObject):
                             nmm:artistName(nmm:artist(?song)) AS ?artist
                             nie:title(nmm:musicAlbum(?song)) AS ?album
                             nfo:duration(?song) AS ?duration
+                            ?url
                         WHERE {
                             ?song a nmm:MusicPiece ;
                                   nie:isStoredAs ?url .
                             %(location_filter)s
+                            FILTER (
+                                %(filter_clause_song)s
+                            )
                         }
                     }
                 }
@@ -644,12 +649,13 @@ class Playlist(GObject.GObject):
                     FILTER( ?tag = nao:predefined-tag-favorite )
                 }
                 FILTER (
-                   %(filter_clause)s
+                    %(filter_clause_pl)s
                 )
             }
             """.replace("\n", " ").strip() % {
                 "media_type": int(Grl.MediaType.AUDIO),
-                "filter_clause": "tracker:id(?song) = " + media_id,
+                "filter_clause_song": "tracker:id(?song) = " + media_id,
+                "filter_clause_pl": "tracker:id(?playlist) = " + pl_id,
                 "location_filter": self._tracker_wrapper.location_filter(),
                 "miner_fs_busname": miner_fs_busname,
             }


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