From ff605bf57f2032f91a8432c16e347a46495f2386 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Fri, 3 Sep 2021 21:49:16 +0100 Subject: [PATCH] Update GET_PLAN to GETPLAN and add SETPLAYED --- player.py | 11 ++++++----- websocket_server.py | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/player.py b/player.py index 8ef5b06..48a2c11 100644 --- a/player.py +++ b/player.py @@ -598,14 +598,14 @@ class Player: return success - def reset_played(self, weight: int): + def set_played(self, weight: int, played: bool): plan: List[PlanItem] = self.state.get()["show_plan"] if weight == -1: for item in plan: - item.play_count_reset() + item.play_count_increment() if played else item.play_count_reset() self.state.update("show_plan", plan) elif len(plan) > weight: - plan[weight].play_count_reset() + plan[weight].play_count_increment() if played else plan[weight].play_count_reset() self.state.update("show_plan", plan[weight], weight) else: return False @@ -1001,7 +1001,7 @@ class Player: ) ), # Show Plan Items - "GET_PLAN": lambda: self._retMsg( + "GETPLAN": lambda: self._retMsg( self.get_plan(int(self.last_msg.split(":")[1])) ), "LOAD": lambda: self._retMsg( @@ -1021,7 +1021,8 @@ class Player: ), "CLEAR": lambda: self._retMsg(self.clear_channel_plan()), "SETMARKER": lambda: self._retMsg(self.set_marker(self.last_msg.split(":")[1], self.last_msg.split(":", 2)[2])), - "RESETPLAYED": lambda: self._retMsg(self.reset_played(int(self.last_msg.split(":")[1]))), + "RESETPLAYED": lambda: self._retMsg(self.set_played(weight=int(self.last_msg.split(":")[1]), played = False)), + "SETPLAYED": lambda: self._retMsg(self.set_played(weight=int(self.last_msg.split(":")[1]), played = True)), "SETLIVE": lambda: self._retMsg(self.set_live(self.last_msg.split(":")[1] == "True")), } diff --git a/websocket_server.py b/websocket_server.py index 594b552..5be356d 100644 --- a/websocket_server.py +++ b/websocket_server.py @@ -146,7 +146,9 @@ class WebsocketServer: extra += str(data["weight"]) elif command == "RESETPLAYED": extra += str(data["weight"]) - elif command == "GET_PLAN": + elif command == "SETPLAYED": + extra += str(data["weight"]) + elif command == "GETPLAN": extra += str(data["timeslotId"]) elif command == "SETMARKER": extra += "{}:{}".format(