From d32b466d1f9f44cd3ecbdf9381327b872c6a2d64 Mon Sep 17 00:00:00 2001
From: David Trattnig <david.trattnig@o94.at>
Date: Fri, 13 Nov 2020 12:54:07 +0100
Subject: [PATCH] Clear timeslot when it ended. #41

---
 src/core/events.py          |  1 +
 src/plugins/trackservice.py | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/src/core/events.py b/src/core/events.py
index 8652ae4d..ee0255d3 100644
--- a/src/core/events.py
+++ b/src/core/events.py
@@ -103,6 +103,7 @@ class EngineEventDispatcher():
 
         binding = self.attach(TrackServiceHandler)
         binding.subscribe("on_timeslot_start")
+        binding.subscribe("on_timeslot_end")
         binding.subscribe("on_play")
         binding.subscribe("on_metadata")
         binding.subscribe("on_queue")
diff --git a/src/plugins/trackservice.py b/src/plugins/trackservice.py
index 2c3935e5..f62a67cb 100644
--- a/src/plugins/trackservice.py
+++ b/src/plugins/trackservice.py
@@ -62,6 +62,17 @@ class TrackServiceHandler():
         self.playlog.set_timeslot(timeslot)
 
 
+
+    def on_timeslot_end(self, timeslot):
+        """
+        Called when a timeslot ends.
+        """
+        if timeslot:
+            self.logger.info(f"Timeslot '{timeslot}' just ended")
+        self.playlog.set_timeslot(None)
+
+
+
     def on_queue(self, entries):
         """
         Items have been queued. They are stored to the local playlog, allowing later
-- 
GitLab