[gnome-music/songeditor-tracker3: 17/32] coregrilo: Handle a list of keys for writeback



commit e4789281d7abaede21590ca231ffb4afae5c82e0
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 can be updated with a single call.

 gnomemusic/coregrilo.py | 8 ++++----
 gnomemusic/coresong.py  | 7 ++++---
 2 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index 3ce407d5..8c62bffe 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -212,11 +212,11 @@ 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:
@@ -228,7 +228,7 @@ class CoreGrilo(GObject.GObject):
         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 c329971a..c0a8f111 100644
--- a/gnomemusic/coresong.py
+++ b/gnomemusic/coresong.py
@@ -99,7 +99,8 @@ class CoreSong(GObject.GObject):
             return
 
         self.props.media.set_favourite(self._favorite)
-        self._coregrilo.writeback(self.props.media, Grl.METADATA_KEY_FAVOURITE)
+        self._coregrilo.writeback(
+            self.props.media, [Grl.METADATA_KEY_FAVOURITE])
 
     @GObject.Property(type=bool, default=False)
     def selected(self):
@@ -134,7 +135,7 @@ class CoreSong(GObject.GObject):
 
         self.props.media.set_play_count(self.props.play_count + 1)
         self._coregrilo.writeback(
-            self.props.media, Grl.METADATA_KEY_PLAY_COUNT)
+            self.props.media, [Grl.METADATA_KEY_PLAY_COUNT])
 
     def set_last_played(self):
         if not self._is_tracker:
@@ -142,7 +143,7 @@ class CoreSong(GObject.GObject):
 
         self.props.media.set_last_played(GLib.DateTime.new_now_utc())
         self._coregrilo.writeback(
-            self.props.media, Grl.METADATA_KEY_LAST_PLAYED)
+            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]