async def run(self): while True: emitter.emit("METADATA_GET") metadata = emitter.emit("METADATA_STATE") if metadata.play_now and metadata.name: emitter.emit("NOTIFICATION", metadata.play_now, metadata.name) log.info(metadata) self.update(metadata) await asyncio.sleep(120)
def list(event, **kwargs): list_buffer = event.app.layout.get_buffer_by_name(LISTVIEW_BUFFER) subcommand = kwargs["variables"].get("subcommand") term = kwargs["variables"].get("term") resp = emitter.emit("RADIO_SEARCH", command=subcommand, term=term) stations.new(*resp) list_buffer.update(str(stations))
def play(event, **kwargs): call_command_handler("stop", event) list_buffer = event.app.layout.get_buffer_by_name(LISTVIEW_BUFFER) index = list_buffer.get_index(**kwargs) station = stations[int(index)] emitter.emit("RADIO_PLAY", station) emitter.emit("METADATA_INIT", station) display_buffer = event.app.layout.get_buffer_by_name(DISPLAY_BUFFER) emitter.emit("METADATA_GET") metadata = emitter.emit("METADATA_STATE") display_buffer.update(metadata)
def _(event): emitter.emit("RADIO_STOP")
def _(event): event.app.exit() emitter.emit("KILLALL")
def stop(event, **kwargs): display_buffer = event.app.layout.get_buffer_by_name(DISPLAY_BUFFER) display_buffer.clear() emitter.emit("RADIO_STOP")
def exit(event, **kwargs): """ exit Ctrl + Q""" emitter.emit("KILLALL") event.app.exit()
def pause(event, **kwargs): emitter.emit("RADIO_PAUSE")