From 3e0d7617d5081f4a4a87cf9c203d14ab6c0b25da Mon Sep 17 00:00:00 2001 From: taizan-hokuto <55448286+taizan-hokuto@users.noreply.github.com> Date: Mon, 11 Nov 2019 20:07:18 +0900 Subject: [PATCH] Make sure to quit when failed to get replay chat data --- pytchat/core_multithread/replayparser.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pytchat/core_multithread/replayparser.py b/pytchat/core_multithread/replayparser.py index 896c11a..bec801d 100644 --- a/pytchat/core_multithread/replayparser.py +++ b/pytchat/core_multithread/replayparser.py @@ -12,7 +12,6 @@ logger = mylogger.get_logger(__name__,mode=config.LOGGER_MODE) class Parser: def parse(self, jsn): - #print(jsn) if jsn is None: return {'timeoutMs':0,'continuation':None},[] if jsn['response']['responseContext'].get('errors'): @@ -33,14 +32,13 @@ class Parser: metadata = cont.get(unknown) actions = contents['liveChatContinuation'].get('actions') + if actions is None: + raise NoContentsException('チャットデータを取得できませんでした。') interval = self.get_interval(actions) metadata.setdefault("timeoutMs",interval) - print(metadata["continuation"]) - chatdata = [] for action in actions: chatdata.append(action["replayChatItemAction"]["actions"][0]) - #print(chatdata) return metadata, chatdata def get_interval(self, actions: list): @@ -48,9 +46,6 @@ class Parser: return 0 start = int(actions[0]["replayChatItemAction"]["videoOffsetTimeMsec"]) last = int(actions[-1]["replayChatItemAction"]["videoOffsetTimeMsec"]) - print((last - start)/1000) - if (last - start) > 60*20*1000: - return 60000 return (last - start)