use get_first() and remove .get()

This commit is contained in:
jakeogh 2024-05-14 18:55:02 -07:00
parent 6f5c669fcc
commit f6ced29596
1 changed files with 5 additions and 3 deletions

View File

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