X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Fplugins%2Fcore%2Funiq.py;h=1abdd62a8f492ee805f53f877afc4d34567f80ba;hb=c88354dc91b4f22af14b70e2fa2654f2f57438e3;hp=969af6cf4c0d13d871469c19669b2bcfd020885e;hpb=4414e379aa08c465416d5f2bdbc4e9292170f6d8;p=mpd-sima.git diff --git a/sima/plugins/core/uniq.py b/sima/plugins/core/uniq.py index 969af6c..1abdd62 100644 --- a/sima/plugins/core/uniq.py +++ b/sima/plugins/core/uniq.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2013, 2014 Jack Kaliko +# Copyright (c) 2014 Jack Kaliko # # This file is part of sima # @@ -18,7 +18,9 @@ # # """ - Deal with MPD options ‑ idle and repeat mode + Publish presence on the MPD host message bus + + Notifies when concurrent instance run on the same host. """ # standard library import @@ -38,21 +40,23 @@ class Uniq(Plugin): def __init__(self, daemon): Plugin.__init__(self, daemon) - self.capable = False self.chan = 'mpd_sima:{0}.{1}'.format(getfqdn(), getpid()) self.channels = [] self.uniq = True - self.is_capable() - if not self.capable: + + 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() def is_capable(self): - if 'channels' in self.player.commands(): - self.capable = True - return - self.log.warning('MPD does not provide client to client') + 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): return [chan for chan in self.player.channels() if @@ -70,7 +74,7 @@ class Uniq(Plugin): self.player.subscribe(self.chan) def callback_need_track(self): - if self.capable: + if self.is_capable(): self.is_uniq()