From 157f3b99522877c604ae56fa66abc8cd8e63092d Mon Sep 17 00:00:00 2001 From: taizan-hokuto <55448286+taizan-hokuto@users.noreply.github.com> Date: Mon, 7 Sep 2020 23:28:03 +0900 Subject: [PATCH] Fix handling when missing id and type --- pytchat/tool/extract/parser.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pytchat/tool/extract/parser.py b/pytchat/tool/extract/parser.py index a2568a4..2866af2 100644 --- a/pytchat/tool/extract/parser.py +++ b/pytchat/tool/extract/parser.py @@ -42,10 +42,14 @@ def get_offset(item): def get_id(item): - return list((list(item['replayChatItemAction']["actions"][0].values() - )[0])['item'].values())[0].get('id') + a = list(item['replayChatItemAction']["actions"][0].values())[0].get('item') + if a: + return list(a.values())[0].get('id') + return None def get_type(item): - return list((list(item['replayChatItemAction']["actions"][0].values() - )[0])['item'].keys())[0] + a = list(item['replayChatItemAction']["actions"][0].values())[0].get('item') + if a: + return list(a.keys())[0] + return None