[gnome-music/wip/mschraal/tageditor: 17/21] MB plugin loading new style



commit e385fc14c24ae8b153e1b236a19299e8af8c27d9
Author: Marinus Schraal <mschraal gnome org>
Date:   Fri Nov 22 15:19:06 2019 +0100

    MB plugin loading new style

 gnomemusic/coregrilo.py                        | 36 ++++++++++++++------------
 gnomemusic/grilowrappers/grlacoustidwrapper.py |  2 --
 2 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index dae92585..4d6a59ab 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -27,6 +27,9 @@ gi.require_version('Grl', '0.3')
 from gi.repository import Grl, GLib, GObject
 
 # from gnomemusic.grilowrappers.grldleynawrapper import GrlDLeynaWrapper
+from gnomemusic.grilowrappers.grlacoustidwrapper import GrlAcoustIDWrapper
+from gnomemusic.grilowrappers.grlchromaprintwrapper import (
+    GrlChromaprintWrapper)
 from gnomemusic.grilowrappers.grlsearchwrapper import GrlSearchWrapper
 from gnomemusic.grilowrappers.grltrackerwrapper import GrlTrackerWrapper
 from gnomemusic.grilowrappers.grlmusicbrainzwrapper import (
@@ -36,13 +39,6 @@ from gnomemusic.trackerwrapper import TrackerState, TrackerWrapper
 
 class CoreGrilo(GObject.GObject):
 
-    __gsignals__ = {
-        "new-resolve-source-found": (
-            GObject.SignalFlags.RUN_FIRST, None, (Grl.Source, )),
-        "new-query-source-found": (
-            GObject.SignalFlags.RUN_FIRST, None, (Grl.Source, )),
-    }
-
     _blacklist = [
         'grl-bookmarks',
         'grl-filesystem',
@@ -56,6 +52,7 @@ class CoreGrilo(GObject.GObject):
                          "grl-lastfm-cover:2,"
                          "grl-theaudiodb-cover:1")
 
+    _acoustid_api_key = "Nb8SVVtH1C"
     _theaudiodb_api_key = "195003"
 
     cover_sources = GObject.Property(type=bool, default=False)
@@ -75,9 +72,11 @@ class CoreGrilo(GObject.GObject):
         self._application = application
         self._coremodel = coremodel
         self._coreselection = application.props.coreselection
-        self._search_wrappers = {}
         self._thumbnail_sources = []
         self._thumbnail_sources_timeout = None
+
+        self._mb_wrappers = {}
+        self._search_wrappers = {}
         self._wrappers = {}
 
         self._tracker_wrapper = TrackerWrapper()
@@ -97,11 +96,14 @@ class CoreGrilo(GObject.GObject):
         config.set_api_key(self._theaudiodb_api_key)
         self._registry.add_config(config)
 
+        config = Grl.Config.new("grl-lua-factory", "grl-acoustid")
+        config.set_api_key(self._acoustid_api_key)
+        self._registry.add_config(config)
+
         self._registry.connect('source-added', self._on_source_added)
         self._registry.connect('source-removed', self._on_source_removed)
 
         self._registry.load_all_plugins(True)
-        self._musicbrainz = GrlMusicbrainzWrapper(self)
 
     def _on_tracker_available_changed(self, klass, value):
         new_state = self._tracker_wrapper.props.tracker_available
@@ -161,14 +163,12 @@ class CoreGrilo(GObject.GObject):
             self._search_wrappers[source.props.source_id] = GrlSearchWrapper(
                 source, self._coremodel, self._coreselection, self)
             print("search source", source)
-
-        elif (source.supported_operations() & Grl.SupportedOps.RESOLVE
-                and source.get_supported_media() & Grl.MediaType.AUDIO):
-            self.emit("new-resolve-source-found", source)
-
-        elif (source.supported_operations() & Grl.SupportedOps.QUERY
-                and source.get_supported_media() & Grl.MediaType.AUDIO):
-            self.emit("new-query-source-found", source)
+        elif source.get_id() == "grl-acoustid":
+            self._mb_wrappers[source.props.source_id] = GrlAcoustIDWrapper(
+                source, self)
+        elif source.get_id() == "grl-chromaprint":
+            self._mb_wrappers[source.props.source_id] = GrlChromaprintWrapper(
+                source, self)
 
     def _on_source_removed(self, registry, source):
         # FIXME: Handle removing sources.
@@ -177,6 +177,8 @@ class CoreGrilo(GObject.GObject):
         # FIXME: Only removes search sources atm.
         self._search_wrappers.pop(source.props.source_id, None)
 
+        self._mb_wrappers.pop(source.props.source_id, None)
+
     def get_artist_albums(self, artist, filter_model):
         for wrapper in self._wrappers.values():
             wrapper.get_artist_albums(artist, filter_model)
diff --git a/gnomemusic/grilowrappers/grlacoustidwrapper.py b/gnomemusic/grilowrappers/grlacoustidwrapper.py
index e66a1625..c83058b3 100644
--- a/gnomemusic/grilowrappers/grlacoustidwrapper.py
+++ b/gnomemusic/grilowrappers/grlacoustidwrapper.py
@@ -31,8 +31,6 @@ class GrlAcoustIDWrapper(GObject.GObject):
     """Wrapper for the Grilo AcoustID source.
     """
 
-    _acoustid_api_key = "Nb8SVVtH1C"
-
     _ACOUSTID_METADATA_KEYS = [
         Grl.METADATA_KEY_ALBUM,
         Grl.METADATA_KEY_ALBUM_DISC_NUMBER,


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