-def command(payload):
- future = asyncio.Future()
- if payload:
- cli = MPDProto(future, payload)
+class MPDClient:
+ loop = asyncio.get_event_loop()
+
+ def __init__(self, host='localhost', port=6600):
+ self._host = host
+ self._port = port
+ self._commands = {
+ 'currentsong',
+ 'stats',
+ }
+
+ def __getattr__(self, attr):
+ command = attr
+ wrapper = self._command
+ if command not in self._commands:
+ command = command.replace("_", " ")
+ if command not in self._commands:
+ raise AttributeError("'%s' object has no attribute '%s'" %
+ (self.__class__.__name__, attr))
+ return lambda *args: wrapper(command, args)
+
+ def _command(self, command, args):
+ # TODO: deal with encoding
+ payload = '{} {}'.format(command ,''.join(args))
+ future = asyncio.Future()