[gnome-music/wip/mschraal/tageditor-13feb2020: 35/41] coregrilo: Handle a list of keys for writeback
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/tageditor-13feb2020: 35/41] coregrilo: Handle a list of keys for writeback
- Date: Sat, 15 Feb 2020 21:40:17 +0000 (UTC)
commit 3dfc1074cfda83893bfc0d065f1fc8f060df6b96
Author: Jean Felder <jfelder src gnome org>
Date: Sat Nov 23 16:37:53 2019 +0100
coregrilo: Handle a list of keys for writeback
Several metadata keys can be updated with a single call.
gnomemusic/coregrilo.py | 11 ++++++-----
gnomemusic/coresong.py | 6 +++---
2 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index 4d94dbc2..fc8a48b9 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -180,23 +180,24 @@ class CoreGrilo(GObject.GObject):
for wrapper in self._wrappers.values():
wrapper.populate_album_disc_songs(media, discnr, callback)
- def writeback(self, media, key):
- """Store the values associated with the key.
+ def writeback(self, media, keys):
+ """Store the values associated with the keys.
:param Grl.Media media: A Grilo media item
- :param int key: a Grilo metadata key
+ :param list keys: A list of Grilo metadata keys
"""
def _store_metadata_cb(source, media, failed_keys, data, error):
if error is not None:
self._log.warning(
"Error {}: {}".format(error.domain, error.message))
if failed_keys:
- self._log.warning("Unable to update {}".format(failed_keys))
+ self._log.warning(
+ "Unable to writeback {}".format(failed_keys))
for wrapper in self._wrappers.values():
if media.get_source() == wrapper.source.props.source_id:
wrapper.props.source.store_metadata(
- media, [key], Grl.WriteFlags.NORMAL, _store_metadata_cb,
+ media, keys, Grl.WriteFlags.NORMAL, _store_metadata_cb,
None)
break
diff --git a/gnomemusic/coresong.py b/gnomemusic/coresong.py
index f8d5d422..ec8d2371 100644
--- a/gnomemusic/coresong.py
+++ b/gnomemusic/coresong.py
@@ -94,7 +94,7 @@ class CoreSong(GObject.GObject):
return
self.props.media.set_favourite(self._favorite)
- self._grilo.writeback(self.props.media, Grl.METADATA_KEY_FAVOURITE)
+ self._grilo.writeback(self.props.media, [Grl.METADATA_KEY_FAVOURITE])
@GObject.Property(type=bool, default=False)
def selected(self):
@@ -128,14 +128,14 @@ class CoreSong(GObject.GObject):
return
self.props.media.set_play_count(self.props.play_count + 1)
- self._grilo.writeback(self.props.media, Grl.METADATA_KEY_PLAY_COUNT)
+ self._grilo.writeback(self.props.media, [Grl.METADATA_KEY_PLAY_COUNT])
def set_last_played(self):
if not self._is_tracker:
return
self.props.media.set_last_played(GLib.DateTime.new_now_utc())
- self._grilo.writeback(self.props.media, Grl.METADATA_KEY_LAST_PLAYED)
+ self._grilo.writeback(self.props.media, [Grl.METADATA_KEY_LAST_PLAYED])
def query_musicbrainz_tags(self, callback):
"""Retrieves metadata keys for this CoreSong
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]