X-Git-Url: http://git.kaliko.me/?p=python-musicpd.git;a=blobdiff_plain;f=musicpd.py;h=008d9d8d4838539fad90031ce538d166971fe5b7;hp=f63857c4e8c931097f2a1d6e457ced94f96dd988;hb=e645adfa14a04168a4d8a892e88569205f868c84;hpb=7cb6ba6bfc1dfae2be3ef0047dfeaabc87b81df7 diff --git a/musicpd.py b/musicpd.py index f63857c..008d9d8 100644 --- a/musicpd.py +++ b/musicpd.py @@ -233,6 +233,7 @@ class MPDClient: "listfiles": self._fetch_database, "lsinfo": self._fetch_database, "readcomments": self._fetch_object, + "readpicture": self._fetch_composite, "search": self._fetch_songs, "searchadd": self._fetch_nothing, "searchaddpl": self._fetch_nothing, @@ -393,7 +394,7 @@ class MPDClient: def _read_binary(self, amount): chunk = bytearray() while amount > 0: - result = self._rbfile.recv(amount) + result = self._rbfile.read(amount) if len(result) == 0: self.disconnect() raise ConnectionError("Connection lost while reading binary content") @@ -542,6 +543,10 @@ class MPDClient: obj[key] = value if key == 'binary': break + if not obj: + # If the song file was recognized, but there is no picture, the + # response is successful, but is otherwise empty. + return obj amount = int(obj['binary']) try: obj['data'] = self._read_binary(amount)