[gnome-music] Use Grilo key for setting last played
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] Use Grilo key for setting last played
- Date: Sat, 3 Dec 2016 13:04:37 +0000 (UTC)
commit ae1c99eb953f460871285714eacf680fc4f2e12f
Author: Marinus Schraal <mschraal src gnome org>
Date: Tue Nov 22 22:08:29 2016 +0100
Use Grilo key for setting last played
Use the GRL_METADATA_KEY_LAST_PLAYED to set the last played date-time of
the media. In tracker this is tracked in the nie:contentAccessed
property.
gnomemusic/grilo.py | 13 +++++++++++++
gnomemusic/player.py | 2 +-
gnomemusic/query.py | 2 +-
3 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index 0a90e01..2037022 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -390,4 +390,17 @@ class Grilo(GObject.GObject):
self.tracker.store_metadata_sync(media, [Grl.METADATA_KEY_PLAY_COUNT],
Grl.WriteFlags.NORMAL)
+ @log
+ def set_last_played(self, media):
+ """Sets the date-time when the media was last played
+
+ Sets the last played date-time for the media.
+ :param media: A Grilo media item
+ """
+ media.set_last_played(GLib.DateTime.new_now_utc())
+ # FIXME: We assume this is the tracker plugin.
+ # FIXME: Doing this async crashes
+ self.tracker.store_metadata_sync(media, [Grl.METADATA_KEY_LAST_PLAYED],
+ Grl.WriteFlags.NORMAL)
+
grilo = Grilo()
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index da5004a..6ccb2a4 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -917,7 +917,6 @@ class Player(GObject.GObject):
@log
def scrobble_song(self, url):
# Update playlists
- playlists.update_last_played(url)
playlists.update_all_static_playlists()
if self.last_fm:
@@ -993,6 +992,7 @@ class Player(GObject.GObject):
self.scrobbled = True
if current_media:
grilo.bump_play_count(self.get_current_media())
+ grilo.set_last_played(current_media)
just_played_url = self.get_current_media().get_url()
t = Thread(target=self.scrobble_song, args=(just_played_url,))
t.setDaemon(True)
diff --git a/gnomemusic/query.py b/gnomemusic/query.py
index b5947b5..1a9513e 100644
--- a/gnomemusic/query.py
+++ b/gnomemusic/query.py
@@ -738,7 +738,7 @@ class Query():
WHERE {
?song a nmm:MusicPiece ;
nie:isStoredAs ?as ;
- nfo:fileLastAccessed ?last_played .
+ nie:contentAccessed ?last_played .
?as nie:url ?url .
FILTER ( ?last_played > '%(compare_date)s'^^xsd:dateTime
&& EXISTS { ?song nie:usageCounter ?count .}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]