diff --git a/larigira/event.py b/larigira/event.py index 29c15c0..5d556c4 100644 --- a/larigira/event.py +++ b/larigira/event.py @@ -152,7 +152,13 @@ class Monitor(ParentedLet): 'should play %s' % str(g.value))) audiogen.link_exception(lambda g: self.log.exception( 'Failure in audiogen {}: {}'.format(audiospec, audiogen.exception))) - audiogen.link_value(lambda g: self.send_to_parent('add', g.value)) + audiogen.link_value(lambda g: + self.send_to_parent('add', + dict(uris=g.value, + audiospec=audiospec, + aid=audiospec.eid + )) + ) def _run(self): self.source.start() diff --git a/larigira/mpc.py b/larigira/mpc.py index aa3cf0d..259c708 100644 --- a/larigira/mpc.py +++ b/larigira/mpc.py @@ -70,14 +70,19 @@ class Player(gevent.Greenlet): def enqueue(self, songs): mpd_client = self._get_mpd() - for song in songs: - self.log.info('Adding {} to playlist'.format(song)) + assert type(songs) is dict + assert 'uris' in songs + spec = songs['audiospec'] + for uri in songs['uris']: + assert type(uri) is str + self.log.info('Adding {} to playlist (from {}={})'. + format(uri, songs['aid'], spec)) insert_pos = 0 if len(mpd_client.playlistid()) == 0 else \ int(mpd_client.currentsong().get('pos', 0)) + 1 try: - mpd_client.addid(song, insert_pos) + mpd_client.addid(uri, insert_pos) except CommandError: - self.log.exception("Cannot insert song {}".format(song)) + self.log.exception("Cannot insert song {}".format(uri)) def _run(self): mw = MpcWatcher(self.q, self.conf, client=None)