[gnome-music/wip/smart_playlists: 1/5] Add 'Recently Added' playlist - last 50 added songs
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/smart_playlists: 1/5] Add 'Recently Added' playlist - last 50 added songs
- Date: Tue, 22 Apr 2014 15:40:48 +0000 (UTC)
commit 06f06aa675883aca8dc727f349c28588862b4022
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date: Tue Apr 22 14:30:56 2014 +0200
Add 'Recently Added' playlist - last 50 added songs
gnomemusic/query.py | 17 +++++++++++++++++
gnomemusic/view.py | 16 ++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/gnomemusic/query.py b/gnomemusic/query.py
index fc8b8f3..06b7bd6 100644
--- a/gnomemusic/query.py
+++ b/gnomemusic/query.py
@@ -224,6 +224,23 @@ class Query():
}
'''.replace('\n', ' ').strip()
+ RECENTLY_ADDED = '''
+ 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
+ nie:contentCreated(?song) AS time
+ WHERE {
+ ?song a nmm:MusicPiece ;
+ a nfo:FileDataObject
+ }
+ ORDER BY DESC(?time)
+ '''.replace('\n', ' ').strip()
+
@staticmethod
def album_songs(album_id):
query = '''
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index c1b3112..ef76409 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -1148,6 +1148,7 @@ class Playlist(ViewContainer):
@log
def populate(self):
+ self.add_predefined_playlists()
for item in sorted(self.playlists_list):
self._add_playlist_item(item)
if len(self.playlists_list):
@@ -1161,3 +1162,18 @@ class Playlist(ViewContainer):
def get_selected_track_uris(self, callback):
callback([self.filter.get_value(self.filter.get_iter(path), 5).get_url()
for path in self.view.get_selection()])
+
+ @log
+ def add_predefined_playlists(self):
+ self.add_predefined_playlist(_("Recently Added"), Query.RECENTLY_ADDED)
+
+ @log
+ def add_predefined_playlist(self, name, query):
+ self._on_playlist_created(None, name)
+
+ def _add_predefined_playlist_cb(source, param, item, remaining):
+ if item and item.get_url():
+ 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]