use single traversal

This commit is contained in:
jakeogh 2024-05-14 19:01:41 -07:00
parent f6ced29596
commit 8d428b42c0

View file

@ -3316,12 +3316,14 @@ def _extract_comment(self, view_model, entities, parent=None):
info = {
'id': comment_id,
'text': try_get(comment_entity_payload, lambda x: x['properties']['content']['content'], str),
'like_count': parse_count(try_get(comment_entity_payload, lambda x: x['toolbar']['likeCountA11y'], str)) or 0,
'author_id': traverse_obj(comment_entity_payload, ('author', 'channelId', {self.ucid_or_none})),
'author': try_get(comment_entity_payload, lambda x: x['author']['displayName'], str),
'author_thumbnail': traverse_obj(comment_entity_payload, ('author', 'avatarThumbnailUrl', {url_or_none})),
'parent': parent or 'root',
**traverse_obj(comment_entity_payload, {
'text': ('properties', 'content', 'content', {str}),
'like_count': ('toolbar', 'likeCountA11y', {parse_count}),
'author_id': ('author', 'channelId', {self.ucid_or_none}),
'author': ('author', 'displayName', {str}),
'author_thumbnail': ('author', 'avatarThumbnailUrl', {url_or_none}),
}),
}
# Timestamp is an estimate calculated from the current time and time_text