]> kaliko git repositories - mpd-sima.git/blobdiff - sima/plugins/core/uniq.py
Fixed bad pid in Uniq core plugin (closes #32)
[mpd-sima.git] / sima / plugins / core / uniq.py
index db2caffe41172faf8a27d8750da36f721e3f0800..bc2ef547c41bfe7e5b6f2dc86ec8fecb3f29b97f 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright (c) 2014 Jack Kaliko <kaliko@azylum.org>
+# Copyright (c) 2014, 2020 kaliko <kaliko@azylum.org>
 #
 #  This file is part of sima
 #
@@ -30,7 +30,7 @@ from socket import getfqdn
 # third parties components
 
 # local import
-from ...client import PlayerError
+from ...mpdclient import PlayerError
 from ...lib.plugin import Plugin
 
 
@@ -41,7 +41,7 @@ class Uniq(Plugin):
 
     def __init__(self, daemon):
         Plugin.__init__(self, daemon)
-        self.chan = 'mpd_sima:{0}.{1}'.format(getfqdn(), getpid())
+        self.chan = None
         self.channels = []
         self._registred = False
 
@@ -54,11 +54,10 @@ class Uniq(Plugin):
             self.sub_chan()
 
     def is_capable(self):
-        if {'channels', 'subscribe'}.issubset(set(self.player.commands())):
-            # Groove Basin compatibility
-            # For some reason Groove Basin have channels command but no
-            # subscribe command‽
-            return True
+        # Groove Basin compatibility
+        # For some reason Groove Basin have channels command but no
+        # subscribe command‽
+        return {'channels', 'subscribe'}.issubset(set(self.player.commands()))
 
     def get_channels(self):
         return [chan for chan in self.player.channels() if
@@ -71,7 +70,8 @@ class Uniq(Plugin):
             self.log.warning(' '.join(channels))
 
     def sub_chan(self):
-        self.log.debug('Registering as {}'.format(self.chan))
+        self.chan = 'mpd_sima:{0}.{1}'.format(getfqdn(), getpid())
+        self.log.debug('Registering as %s', self.chan)
         try:
             self.player.subscribe(self.chan)
             self._registred = True