diff --git a/mopidy/frontends/mpd/dispatcher.py b/mopidy/frontends/mpd/dispatcher.py index 05ae976d..65346275 100644 --- a/mopidy/frontends/mpd/dispatcher.py +++ b/mopidy/frontends/mpd/dispatcher.py @@ -48,6 +48,15 @@ class MpdDispatcher(object): ] return self._call_next_filter(request, response, filter_chain) + def _call_next_filter(self, request, response, filter_chain): + if filter_chain: + next_filter = filter_chain.pop(0) + return next_filter(request, response, filter_chain) + else: + return response + + + ### Filter: catch MPD ACK errors def _catch_mpd_ack_errors_filter(self, request, response, filter_chain): try: @@ -58,6 +67,8 @@ class MpdDispatcher(object): return [mpd_ack_error.get_mpd_ack()] + ### Filter: authenticate + def _authenticate_filter(self, request, response, filter_chain): if self.authenticated or settings.MPD_SERVER_PASSWORD is None: return self._call_next_filter(request, response, filter_chain) @@ -69,6 +80,8 @@ class MpdDispatcher(object): raise MpdPermissionError(command=command) + ### Filter: command list + def _command_list_filter(self, request, response, filter_chain): if self._is_receiving_command_list(request): self.command_list.append(request) @@ -90,6 +103,8 @@ class MpdDispatcher(object): and request != u'command_list_end') + ### Filter: add OK + def _add_ok_filter(self, request, response, filter_chain): response = self._call_next_filter(request, response, filter_chain) if not self._has_error(response): @@ -100,6 +115,8 @@ class MpdDispatcher(object): return response and response[-1].startswith(u'ACK') + ### Filter: call handler + def _call_handler_filter(self, request, response, filter_chain): try: response = self._format_response(self._call_handler(request)) @@ -122,14 +139,6 @@ class MpdDispatcher(object): raise MpdArgError(u'incorrect arguments', command=command) raise MpdUnknownCommand(command=command) - - def _call_next_filter(self, request, response, filter_chain): - if filter_chain: - next_filter = filter_chain.pop(0) - return next_filter(request, response, filter_chain) - else: - return response - def _format_response(self, response): formatted_response = [] for element in self._listify_result(response):