# third parties components
# local import
+from ...client import PlayerError
from ...lib.plugin import 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' in self.player.commands():
+ 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
def get_channels(self):
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)
+ try:
+ self.player.subscribe(self.chan)
+ self._registred = True
+ except PlayerError as err:
+ self.log.error('Failed to register: %s', err)
def callback_need_track(self):
if self.is_capable():