[gnome-music/wip/mschraal/grltrackerplaylists-filter-location] grltrackerplaylists: Add location filter to Playlist



commit 8641f63f356dd8dd2e80e042836d9057d7958293
Author: Marinus Schraal <mschraal gnome org>
Date:   Sat Mar 21 16:41:42 2020 +0100

    grltrackerplaylists: Add location filter to Playlist
    
    Since 41c60ec7c35f all the songs in the Playlist are matched to a songs
    in the main songs model. The main songs model only contains songs from
    the filtered location, so any songs in a playlist outside of this
    location crashes Music as the hash match fails.
    
    Add a location filter to the songs queries in Playlist to prevent this
    from happening.

 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 0573a6cd..673fc90c 100644
--- a/gnomemusic/grilowrappers/grltrackerplaylists.py
+++ b/gnomemusic/grilowrappers/grltrackerplaylists.py
@@ -401,10 +401,12 @@ class Playlist(GObject.GObject):
                 NOT EXISTS { ?song a nmm:Video }
                 && NOT EXISTS { ?song a nmm:Playlist }
             )
+            %(location_filter)s
         }
         ORDER BY nfo:listPosition(?entry)
         """.replace('\n', ' ').strip() % {
-            'filter_clause': 'tracker:id(?playlist) = ' + self.props.pl_id
+            "filter_clause": 'tracker:id(?playlist) = ' + self.props.pl_id,
+            "location_filter": self._tracker_wrapper.location_filter()
         }
 
         def _add_to_playlist_cb(
@@ -645,9 +647,13 @@ class Playlist(GObject.GObject):
                     NOT EXISTS { ?song a nmm:Video }
                     && NOT EXISTS { ?song a nmm:Playlist }
                 )
+                %(location_filter)s
             }
             """.replace("\n", " ").strip() % {
-                "filter_clause": "tracker:id(?song) = " + media_id}
+                "filter_clause": "tracker:id(?song) = " + media_id,
+                "location_filter": self._tracker_wrapper.location_filter()
+            }
+
             options = self._fast_options.copy()
             self._source.query(
                 query, self.METADATA_KEYS, options, _add_to_model)


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