diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index 73f7dcaf1..e92907f42 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -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