Don't throw the exception if a certain Snapcast host is not reachable

This commit is contained in:
Fabio Manganiello 2019-01-11 11:50:37 +01:00
parent 29be2945cc
commit 33fd226fa1

View file

@ -569,30 +569,35 @@ class MusicSnapcastPlugin(Plugin):
playing_hosts = {} playing_hosts = {}
def _worker(host, port): def _worker(host, port):
if exclude_local and (host == 'localhost' try:
or host == Config.get('device_id')): if exclude_local and (host == 'localhost'
return or host == Config.get('device_id')):
return
server_status = self.status(host=host, port=port).output server_status = self.status(host=host, port=port).output
client_status = self.status(host=host, port=port, client_status = self.status(host=host, port=port,
client=Config.get('device_id')).output client=Config.get('device_id')).output
if client_status.get('config', {}).get('volume', {}).get('muted'): if client_status.get('config', {}).get('volume', {}).get('muted'):
return return
group = [g for g in server_status.get('groups', {}) group = [g for g in server_status.get('groups', {})
if g.get('id') == client_status.get('group_id')].pop(0) if g.get('id') == client_status.get('group_id')].pop(0)
if group.get('muted'): if group.get('muted'):
return return
stream = [s for s in server_status.get('streams') stream = [s for s in server_status.get('streams')
if s.get('id') == group.get('stream_id')].pop(0) if s.get('id') == group.get('stream_id')].pop(0)
if stream.get('status') != 'playing': if stream.get('status') != 'playing':
return return
playing_hosts[host] = port playing_hosts[host] = port
except Exception as e:
self.logger.warning(('Error while retrieving the status of ' +
'Snapcast host at {}:{}: {}').format(
host, port, str(e)))
workers = [] workers = []