[gnome-music] query: Add query for playlist songs



commit e8b76d260a06308a8bb98437b3d6e36fb0642236
Author: Arnel Borja <arnelborja src gnome org>
Date:   Thu May 29 20:45:28 2014 +0800

    query: Add query for playlist songs

 gnomemusic/query.py |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/gnomemusic/query.py b/gnomemusic/query.py
index eed0387..cd59b2e 100644
--- a/gnomemusic/query.py
+++ b/gnomemusic/query.py
@@ -489,6 +489,48 @@ class Query():
         return query
 
     @staticmethod
+    def playlist_songs(playlist_id):
+        query = '''
+    SELECT
+        rdf:type(?song)
+        tracker:id(?song) AS id
+        nie:url(?song) 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
+    WHERE {
+        ?playlist a nmm:Playlist ;
+            a nfo:MediaList ;
+            nfo:hasMediaFileListEntry ?entry .
+        ?entry a nfo:MediaFileListEntry ;
+            nfo:entryUrl ?url .
+        ?song a nmm:MusicPiece ;
+             a nfo:FileDataObject ;
+             nie:url ?url .
+        FILTER (
+            tracker:id(?playlist) = %(playlist_id)s
+        )
+        FILTER (
+            NOT EXISTS {
+                ?song a nmm:Video
+            } &&
+            NOT EXISTS {
+                ?song a nmm:Playlist
+            }
+        )
+    }
+    ORDER BY
+         nfo:listPosition(?entry)
+    '''.replace('\n', ' ').strip() % {
+            'playlist_id': playlist_id,
+            'music_dir': Query.MUSIC_DIR,
+            'download_dir': Query.DOWNLOAD_DIR
+        }
+
+        return query
+
+    @staticmethod
     def get_album_for_album_id(album_id):
         query = """
     SELECT DISTINCT


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