From 2edaa2e4719e4ec5f3c68c5582dc46221358846d Mon Sep 17 00:00:00 2001 From: khuxkm fbexl Date: Sun, 20 Sep 2020 04:36:02 +0000 Subject: [PATCH] Add DJ timer to 'dj' command output Specifically, store 'broadcast_start' from the AzuraCast API, and use that + current time to calculate how long the DJ has been streaming for. --- tilderadio.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tilderadio.py b/tilderadio.py index d479fa8..dc6a4ae 100644 --- a/tilderadio.py +++ b/tilderadio.py @@ -88,6 +88,7 @@ class Module(ModuleManager.BaseModule): # self.song = data["now_playing"]["song"]["text"] self.is_online = data["live"]["is_live"] self.dj = data["live"]["streamer_name"] + self.broadcast_start = data["live"]["broadcast_start"] #self.listeners = data["listeners"]["current"] def format_nowplaying(self): @@ -289,6 +290,10 @@ class Module(ModuleManager.BaseModule): message = "no one is currently on the air" else: message = f"{self.dj} is now streaming!" + if self.broadcast_start: + now = utils.datetime.utcnow().timestamp() + total_seconds = now - self.broadcast_start + message += " (for {})".format(util.datetime.to_pretty_time(total_seconds)) event["stdout"].write(message) @utils.hook("received.command.slogan") -- 2.34.1