X-Git-Url: http://git.kaliko.me/?a=blobdiff_plain;f=musicpd.py;h=0fe3b671deff665e3ff73c6394ac7d363e9eb693;hb=21c2a1843902d21f559af15cdd3eb8a9f35a8b86;hp=4980c270c641eda68993982db11b074ac14e1faa;hpb=8fec386e0991e20df8bbb0cc99f0bbf621b6d95c;p=python-musicpd.git diff --git a/musicpd.py b/musicpd.py index 4980c27..0fe3b67 100644 --- a/musicpd.py +++ b/musicpd.py @@ -24,7 +24,7 @@ HELLO_PREFIX = "OK MPD " ERROR_PREFIX = "ACK " SUCCESS = "OK" NEXT = "list_OK" -VERSION = '0.4.0' +VERSION = '0.4.2' class MPDError(Exception): @@ -90,7 +90,7 @@ class MPDClient: "clearerror": self._fetch_nothing, "currentsong": self._fetch_object, "idle": self._fetch_list, - "noidle": None, + #"noidle": None, "status": self._fetch_object, "stats": self._fetch_object, # Playback Option Commands @@ -190,6 +190,8 @@ class MPDClient: } def __getattr__(self, attr): + if attr == 'send_noidle': # have send_noidle to cancel idle as well as noidle + return self.noidle() if attr.startswith("send_"): command = attr.replace("send_", "", 1) wrapper = self._send @@ -457,6 +459,14 @@ class MPDClient: else: raise ConnectionError("getaddrinfo returns an empty list") + def noidle(self): + # noidle's special case + if not self._pending or self._pending[0] != 'idle': + raise CommandError('cannot send noidle if send_idle was not called') + del self._pending[0] + self._write_command("noidle") + return self._fetch_list() + def connect(self, host, port): if self._sock is not None: raise ConnectionError("Already connected")