[gnome-music] added 'recently added' playlist, filtered out never-played songs from 'recently played'
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] added 'recently added' playlist, filtered out never-played songs from 'recently played'
- Date: Thu, 22 Jan 2015 12:41:46 +0000 (UTC)
commit 34f13627d98a5803bc38b2927018c601d5a42f44
Author: Maia <maia mcc gmail com>
Date: Wed Jan 21 12:01:15 2015 -0500
added 'recently added' playlist, filtered out never-played songs from 'recently played'
https://bugzilla.gnome.org/show_bug.cgi?id=743310
gnomemusic/playlists.py | 7 +++++++
gnomemusic/query.py | 40 +++++++++++++++++++++++++++++++---------
2 files changed, 38 insertions(+), 9 deletions(-)
---
diff --git a/gnomemusic/playlists.py b/gnomemusic/playlists.py
index 044a7d3..b9840b9 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -61,6 +61,13 @@ class StaticPlaylists:
# TRANSLATORS: this is a playlist name
TITLE = _("Recently Played")
+ class RecentlyAdded:
+ ID = None
+ QUERY = Query.get_recently_added_songs()
+ TAG_TEXT = "RECENTLY_ADDED"
+ # TRANSLATORS: this is a playlist name
+ TITLE = _("Recently Added")
+
class Playlists(GObject.GObject):
__gsignals__ = {
diff --git a/gnomemusic/query.py b/gnomemusic/query.py
index a0180b3..ac806c5 100644
--- a/gnomemusic/query.py
+++ b/gnomemusic/query.py
@@ -958,7 +958,7 @@ class Query():
@staticmethod
def get_most_played_songs():
- # TODO: set playlist size somewhere? Currently default is 5, this is probably too low...
+ # TODO: set playlist size somewhere? Currently default is 50.
query = """
SELECT ?url
WHERE {
@@ -986,23 +986,45 @@ class Query():
return query
def get_recently_played_songs():
+ #TODO: or this could take comparison date as an argument so we don't need to make a date string
in query.py...
+ #TODO: set time interval somewhere? A settings file? (Default is maybe 2 weeks...?)
+
+ days_difference = 7 # currently hardcoding time interval of 7 days
+ seconds_difference = days_difference * SECONDS_PER_DAY
+ compare_date = time.strftime(
+ sparql_midnight_dateTime_format, time.gmtime(time.time() - seconds_difference))
+
+ query = """
+ SELECT ?url
+ WHERE {
+ ?song a nmm:MusicPiece ;
+ nie:isStoredAs ?as ;
+ nfo:fileLastAccessed ?last_played .
+ ?as nie:url ?url .
+ FILTER ( ?last_played > '%(compare_date)s'^^xsd:dateTime )
+ FILTER ( EXISTS { ?song nie:usageCounter ?count .} )
+ } ORDER BY DESC(?last_played)
+ """.replace('\n', ' ').strip() % {'compare_date': compare_date}
+
+ return query
+
+ def get_recently_added_songs():
#TODO: or this could take comparison date as an argument so we don't need to make a date string in
query.py...
#TODO: set time interval somewhere? A settings file? (Default is maybe 2 weeks...?)
-
- days_difference = 7 # currently hardcoding time interval of 3 days
+
+ days_difference = 7 # currently hardcoding time interval of 7 days
seconds_difference = days_difference * SECONDS_PER_DAY
- compare_date = time.strftime(
- sparql_midnight_dateTime_format, time.gmtime(time.time() - seconds_difference))
+ compare_date = time.strftime(sparql_midnight_dateTime_format,
time.gmtime(time.time()-seconds_difference))
query = """
SELECT ?url
WHERE {
?song a nmm:MusicPiece ;
nie:isStoredAs ?as ;
- nfo:fileLastAccessed ?last_played .
+ tracker:added ?added .
?as nie:url ?url .
- FILTER ( ?last_played > '%(compare_date)s'^^xsd:dateTime )
- } ORDER BY DESC(?last_played)
+ FILTER ( ?added > '%(compare_date)s'^^xsd:dateTime )
+ } ORDER BY DESC(?added)
""".replace('\n', ' ').strip() % {'compare_date': compare_date}
return query
@@ -1268,4 +1290,4 @@ class Query():
'playlist_id': playlist_id
}
- return query
+ return query
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]