Fixes on mopidy backend

This commit is contained in:
Fabio Manganiello 2019-02-12 20:45:40 +01:00
parent 148d25f1cb
commit 73d7e9a3ef

View file

@ -38,12 +38,12 @@ class MusicMopidyBackend(Backend):
* Mopidy installed and the HTTP service enabled * Mopidy installed and the HTTP service enabled
""" """
def __init__(self, server='localhost', port=6680, **kwargs): def __init__(self, host='localhost', port=6680, **kwargs):
super().__init__(**kwargs) super().__init__(**kwargs)
self.server = server self.host = host
self.port = int(port) self.port = int(port)
self.url = 'ws://{}:{}/mopidy/ws'.format(server, port) self.url = 'ws://{}:{}/mopidy/ws'.format(host, port)
self._msg_id = 0 self._msg_id = 0
self._latest_status = self._get_tracklist_status() self._latest_status = self._get_tracklist_status()
@ -132,7 +132,7 @@ class MusicMopidyBackend(Backend):
return return
status = {} status = {}
track = event.get('tl_track', {}) track = msg.get('tl_track', {})
if event == 'track_playback_paused': if event == 'track_playback_paused':
status['state'] = 'pause' status['state'] = 'pause'
@ -158,7 +158,7 @@ class MusicMopidyBackend(Backend):
return return
self.bus.post(NewPlayingTrackEvent(status=status, track=track)) self.bus.post(NewPlayingTrackEvent(status=status, track=track))
elif event == 'stream_title_changed': elif event == 'stream_title_changed':
m = re.match('^\s*(.+?)\s+-\s+(.*)\s*$', event.get('title', '')) m = re.match('^\s*(.+?)\s+-\s+(.*)\s*$', msg.get('title', ''))
if not m: if not m:
return return
@ -198,6 +198,8 @@ class MusicMopidyBackend(Backend):
def run(self): def run(self):
super().run() super().run()
self.logger.info('Started Mopidy events backend on {}:{}'.format(
self.host, self.port))
loop = asyncio.new_event_loop() loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop) asyncio.set_event_loop(loop)