diff options
Diffstat (limited to 'jmpc.py')
-rw-r--r-- | jmpc.py | 98 |
1 files changed, 98 insertions, 0 deletions
@@ -0,0 +1,98 @@ +import socket + +class MPDError(Exception): + pass +class ConnectionError(MPDError): + pass +class ProtocolError(MPDError): + pass +class CommandError(MPDError): + pass +class CommandListError(MPDError): + pass + + +class client: + _csock=None + _rfile=None + _wfile=None + def __init__(self): + pass + + def connect(self, host, port, type=socket.SOCK_STREAM): + if self._csock: + raise ConnectionError("Already connected") + + self._csock=socket.socket(socket.AF_INET, type) + self._csock.connect((host, port)) + self._file = self._csock.makefile("rwb") + handshake=self._read() + if handshake[0:len("hello jmpd")]!="hello jmpd": + print("Failed to handshake: %s" % (handshake)) + self.disconnect() + return + self._write("ack") + + + def _read(self): + return self._file.readline().strip() + def _write(self, line): + self._file.write("%s\n" % (line)) + + def disconnect(self): + self._csock.close() + self._csock=None + + def command_list_ok_begin(self): + pass + + def command_list_end(self): + pass + + def update(self): + pass + + def status(self): + pass + + def playid(id): + pass + def stop(self): + pass + + def pause(self): + pass + def resume(self): + pass + + def next(self): + pass + def previous(self): + pass + + def seekid(time): + pass + + # Playlist management + def add(path): + pass + def deleteid(path): + pass + + # volume + def setvol(newvolume): + pass + + # info + def listallinfo(self): + pass + def listplaylistinfo(self): + pass + def currentsong(self): + pass + + +from test import port +client=client() +client.connect('localhost', port) +client.disconnect() |