use get_first() and remove .get()

This commit is contained in:
jakeogh 2024-05-14 18:55:02 -07:00
parent 6f5c669fcc
commit f6ced29596

View file

@ -3308,9 +3308,11 @@ def _extract_heatmap(self, data):
})) or None })) or None
def _extract_comment(self, view_model, entities, parent=None): def _extract_comment(self, view_model, entities, parent=None):
comment_entity_payload = traverse_obj(entities, (..., 'payload', 'commentEntityPayload', {dict}), get_all=False) comment_entity_payload = get_first(entities, ('payload', 'commentEntityPayload', {dict}))
toolbar_entity_payload = traverse_obj(entities, (..., 'payload', 'engagementToolbarStateEntityPayload', {dict}), get_all=False) toolbar_entity_payload = get_first(entities, ('payload', 'engagementToolbarStateEntityPayload', {dict})) or {}
comment_id = comment_entity_payload.get('properties').get('commentId') comment_id = traverse_obj(comment_entity_payload, ('properties', 'commentId', {str}))
if not comment_id:
return
info = { info = {
'id': comment_id, 'id': comment_id,