Keep reloading the MPD plugin in the MPD backend if the plugin crashed or keeps being null

This commit is contained in:
Fabio Manganiello 2018-04-17 09:27:37 +02:00
parent 2186336bbc
commit 15a233a927

View file

@ -27,9 +27,16 @@ class MusicMpdBackend(Backend):
last_state = None
last_track = None
last_playlist = None
plugin = None
while not self.should_stop():
plugin = get_plugin('music.mpd')
while not plugin:
plugin = get_plugin('music.mpd')
if not plugin:
logging.info('Reloading crashed MPD plugin')
plugin = get_plugin('music.mpd', reload=True)
time.sleep(self.poll_seconds)
status = plugin.status().output
track = plugin.currentsong().output
state = status['state'].lower()