From 4f51394aaf054e84271c0fe6752e2b3c060bccd9 Mon Sep 17 00:00:00 2001 From: isaackogan Date: Fri, 13 Sep 2024 18:13:44 -0400 Subject: [PATCH] Add `ignore_broken_payload` to hide the exception for broken payload parsing --- TikTokLive/client/client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/TikTokLive/client/client.py b/TikTokLive/client/client.py index ceb74df..2c40163 100644 --- a/TikTokLive/client/client.py +++ b/TikTokLive/client/client.py @@ -65,6 +65,9 @@ def __init__( level=LogLevel.ERROR ) + # Overridable properties + self.ignore_broken_payload: bool = False + # Properties self._unique_id: str = self.parse_unique_id(unique_id) self._room_id: Optional[int] = None @@ -359,7 +362,8 @@ def _parse_webcast_response(self, response: Optional[WebcastResponseMessage]) -> try: proto_event: ProtoEvent = event_type().parse(response.payload) except Exception: - self._logger.error(traceback.format_exc() + "\nBroken Payload:\n" + str(response.payload)) + if not self.ignore_broken_payload: + self._logger.error(traceback.format_exc() + "\nBroken Payload:\n" + str(response.payload)) return [response_event] parsed_events: List[Event] = [response_event, proto_event]