Commit ae1c99eb authored by Marinus Schraal's avatar Marinus Schraal

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.
parent 252083a9
...@@ -390,4 +390,17 @@ class Grilo(GObject.GObject): ...@@ -390,4 +390,17 @@ class Grilo(GObject.GObject):
self.tracker.store_metadata_sync(media, [Grl.METADATA_KEY_PLAY_COUNT], self.tracker.store_metadata_sync(media, [Grl.METADATA_KEY_PLAY_COUNT],
Grl.WriteFlags.NORMAL) 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() grilo = Grilo()
...@@ -917,7 +917,6 @@ class Player(GObject.GObject): ...@@ -917,7 +917,6 @@ class Player(GObject.GObject):
@log @log
def scrobble_song(self, url): def scrobble_song(self, url):
# Update playlists # Update playlists
playlists.update_last_played(url)
playlists.update_all_static_playlists() playlists.update_all_static_playlists()
if self.last_fm: if self.last_fm:
...@@ -993,6 +992,7 @@ class Player(GObject.GObject): ...@@ -993,6 +992,7 @@ class Player(GObject.GObject):
self.scrobbled = True self.scrobbled = True
if current_media: if current_media:
grilo.bump_play_count(self.get_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() just_played_url = self.get_current_media().get_url()
t = Thread(target=self.scrobble_song, args=(just_played_url,)) t = Thread(target=self.scrobble_song, args=(just_played_url,))
t.setDaemon(True) t.setDaemon(True)
......
...@@ -738,7 +738,7 @@ class Query(): ...@@ -738,7 +738,7 @@ class Query():
WHERE { WHERE {
?song a nmm:MusicPiece ; ?song a nmm:MusicPiece ;
nie:isStoredAs ?as ; nie:isStoredAs ?as ;
nfo:fileLastAccessed ?last_played . nie:contentAccessed ?last_played .
?as nie:url ?url . ?as nie:url ?url .
FILTER ( ?last_played > '%(compare_date)s'^^xsd:dateTime FILTER ( ?last_played > '%(compare_date)s'^^xsd:dateTime
&& EXISTS { ?song nie:usageCounter ?count .} && EXISTS { ?song nie:usageCounter ?count .}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment