From d62a3a1b1bf2eda1186aa8bf94bd33c1b54c4d59 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sun, 6 Nov 2011 20:29:46 +0100 Subject: mpd plugins now accepts a password and catches some errors. --- plugins/mpd_client.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/mpd_client.py b/plugins/mpd_client.py index 6298a729..5207a0d6 100644 --- a/plugins/mpd_client.py +++ b/plugins/mpd_client.py @@ -10,9 +10,19 @@ class Plugin(BasePlugin): def command_mpd(self, args): args = shell_split(args) - c = mpd.MPDClient() + c = mpd.MPDClient() + try: c.connect(host=self.config.get('host', 'localhost'), port=self.config.get('host', '6600')) - + except Exception as e: + self.core.information('%s' % (e,), 'Error') + return + password = self.config.get('password', '') + if password: + try: + c.password(password) + except Exception as e: + self.core.information('%s' % (e,), 'Error') + return current = c.currentsong() current_time = float(c.status()['elapsed']) -- cgit v1.2.3