parent
fd1e746cea
commit
0840cf51b0
2 changed files with 31 additions and 1 deletions
|
@ -60,6 +60,7 @@ class Player:
|
|||
self.min_playlist_length = 10
|
||||
self.tmpcleaner = UnusedCleaner(conf)
|
||||
self._continous_audiospec = self.conf['CONTINOUS_AUDIOSPEC']
|
||||
self.events_enabled = True
|
||||
|
||||
def _get_mpd(self):
|
||||
mpd_client = MPDClient(use_unicode=True)
|
||||
|
@ -106,10 +107,15 @@ class Player:
|
|||
picker.start()
|
||||
|
||||
def enqueue(self, songs):
|
||||
mpd_client = self._get_mpd()
|
||||
assert type(songs) is dict
|
||||
assert 'uris' in songs
|
||||
spec = [aspec.get('nick', aspec.eid) for aspec in songs['audiospecs']]
|
||||
if not self.events_enabled:
|
||||
self.log.debug('Ignoring <{}> (events disabled)'.format(
|
||||
','.join(spec)
|
||||
))
|
||||
return
|
||||
mpd_client = self._get_mpd()
|
||||
for uri in reversed(songs['uris']):
|
||||
assert type(uri) is str
|
||||
self.log.info('Adding {} to playlist (from <{}>:{}={})'.
|
||||
|
|
|
@ -67,6 +67,30 @@ def reset_audiospec():
|
|||
return jsonify(player.continous_audiospec)
|
||||
|
||||
|
||||
@rpc.route('/eventsenabled/toggle', methods=['POST'])
|
||||
def toggle_events_enabled():
|
||||
status = current_app.larigira.controller.player.events_enabled
|
||||
current_app.larigira.controller.player.events_enabled = not status
|
||||
return jsonify(dict(events_enabled=not status))
|
||||
|
||||
|
||||
@rpc.route('/eventsenabled', methods=['GET'])
|
||||
def get_events_enabled():
|
||||
status = current_app.larigira.controller.player.events_enabled
|
||||
return jsonify(dict(events_enabled=status))
|
||||
|
||||
|
||||
@rpc.route('/eventsenabled', methods=['PUT'])
|
||||
def set_events_enabled():
|
||||
player = current_app.larigira.controller.player
|
||||
if request.json is None:
|
||||
abort(400, "Must send application/json data")
|
||||
if type(request.json) is not bool:
|
||||
abort(400, "Content must be a JSON boolean")
|
||||
player.events_enabled = request.json
|
||||
return jsonify(dict(events_enabled=request.json))
|
||||
|
||||
|
||||
def get_scheduled_audiogen():
|
||||
larigira = current_app.larigira
|
||||
running = larigira.controller.monitor.running
|
||||
|
|
Loading…
Reference in a new issue