]> kaliko git repositories - mpd-sima.git/commitdiff
Fixed bug in uniq plugin
authorkaliko <kaliko@azylum.org>
Sun, 9 Aug 2015 12:56:46 +0000 (14:56 +0200)
committerkaliko <kaliko@azylum.org>
Sun, 9 Aug 2015 12:56:46 +0000 (14:56 +0200)
sima/core.py
sima/plugins/core/uniq.py

index 264d97e144e108f45a3794c955c70f232a3156da..60f6b2b08a0f85ba7854d204e4127ba5723edd9b 100644 (file)
@@ -162,10 +162,10 @@ class Sima(Daemon):
         try:
             self.log.info('Connecting MPD: {0}:{1}'.format(*self.player._mpd))
             self.player.connect()
+            self.foreach_plugin('start')
         except (PlayerError, PlayerUnHandledError) as err:
             self.log.warning('Player: {}'.format(err))
             self.reconnect_player()
-        self.foreach_plugin('start')
         while 42:
             try:
                 self.loop()
index 1abdd62a8f492ee805f53f877afc4d34567f80ba..0f42718ed992b89f8516788ea525e275269d773c 100644 (file)
@@ -42,14 +42,15 @@ class Uniq(Plugin):
         Plugin.__init__(self, daemon)
         self.chan = 'mpd_sima:{0}.{1}'.format(getfqdn(), getpid())
         self.channels = []
-        self.uniq = True
+        self._registred = False
 
     def start(self):
         if not self.is_capable():
             self.log.warning('MPD does not provide client to client')
             return
         self.is_uniq()
-        self.sub_chan()
+        if not self._registred:
+            self.sub_chan()
 
     def is_capable(self):
         if {'channels', 'subscribe'}.issubset(set(self.player.commands())):
@@ -67,11 +68,11 @@ class Uniq(Plugin):
         if channels:
             self.log.warning('Another instance is queueing on this MPD host')
             self.log.warning(' '.join(channels))
-            self.uniq = False
 
     def sub_chan(self):
         self.log.debug('Registering as {}'.format(self.chan))
         self.player.subscribe(self.chan)
+        self._registred = True
 
     def callback_need_track(self):
         if self.is_capable():