[gnome-music/wip/mschraal/triggered-art-update: 1/2] grilo: Check if there are any sources available



commit 8d8a8d621663789b81375e8eb4b780383576736c
Author: Marinus Schraal <mschraal gnome org>
Date:   Thu Sep 27 22:39:59 2018 +0200

    grilo: Check if there are any sources available

 gnomemusic/grilo.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index 890918be..c904b6a7 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -117,6 +117,9 @@ class Grilo(GObject.GObject):
         self.changes_pending = {'Albums': False, 'Artists': False, 'Songs': False}
         self.pending_changed_medias = []
 
+        self._thumbnail_sources = []
+        self._thumbnail_sources_timeout = None
+
         self.registry = Grl.Registry.get_default()
 
         self.sparqltracker = TrackerWrapper().tracker
@@ -201,6 +204,13 @@ class Grilo(GObject.GObject):
         self.emit('changes-pending')
         return False
 
+    @log
+    def _trigger_art_update(self):
+        self._thumbnail_sources_timeout = None
+        print("UPDATE", self._thumbnail_sources)
+
+        return GLib.SOURCE_REMOVE
+
     @log
     def _on_source_added(self, pluginRegistry, mediaSource):
         if ("net:plaintext" in mediaSource.get_tags()
@@ -212,6 +222,13 @@ class Grilo(GObject.GObject):
                     "Failed to unregister {}".format(mediaSource.get_id()))
             return
 
+        if Grl.METADATA_KEY_THUMBNAIL in mediaSource.supported_keys():
+            self._thumbnail_sources.append(mediaSource)
+            print("source can cover", mediaSource.props.source_name)
+            if not self._thumbnail_sources_timeout:
+                self._thumbnail_sources_timeout = GLib.timeout_add_seconds(
+                    5, self._trigger_art_update)
+
         id = mediaSource.get_id()
         logger.debug("new grilo source %s was added", id)
         try:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]