[gnome-music/wip/smart_playlists: 2/5] Add 'Recently Played' playlist



commit 0bfe89c816a5d1c5e3098c6ffba5f28b1c768f48
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date:   Tue Apr 22 14:31:35 2014 +0200

    Add 'Recently Played' playlist

 gnomemusic/query.py |   16 ++++++++++++++++
 gnomemusic/view.py  |    2 +-
 2 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/gnomemusic/query.py b/gnomemusic/query.py
index 06b7bd6..2c3610a 100644
--- a/gnomemusic/query.py
+++ b/gnomemusic/query.py
@@ -241,6 +241,22 @@ class Query():
         ORDER BY DESC(?time)
     '''.replace('\n', ' ').strip()
 
+    RECENTLY_PLAYED = '''
+        SELECT DISTINCT
+            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 {
+          ?song a nmm:MusicPiece ;
+                a nfo:FileDataObject
+        }
+        ORDER BY nie:contentAccessed(?song)
+    '''.replace('\n', ' ').strip()
+
     @staticmethod
     def album_songs(album_id):
         query = '''
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index ef76409..4fb5936 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -1166,6 +1166,7 @@ class Playlist(ViewContainer):
     @log
     def add_predefined_playlists(self):
         self.add_predefined_playlist(_("Recently Added"), Query.RECENTLY_ADDED)
+        self.add_predefined_playlist(_("Recently Played"), Query.RECENTLY_PLAYED)
 
     @log
     def add_predefined_playlist(self, name, query):
@@ -1176,4 +1177,3 @@ class Playlist(ViewContainer):
                 self._on_song_added_to_playlist(None, name, item)
 
         grilo.populate_items(query, 0, _add_predefined_playlist_cb)
-


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