Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/instagram.py (Python)

Code before:
            'url': format.get('url'),
            'width': format.get('width'),
            'height': format.get('height'),
            'vcodec': vcodec,
        } for format in videos_list or []]
        if dash_manifest_raw:
            formats.extend(self._parse_mpd_formats(self._parse_xml(dash_manifest_raw, media_id), mpd_id='dash'))
        self._sort_formats(formats)

        thumbnails = [{
            'url': thumbnail.get('url'),
            'width': thumbnail.get('width'),
            'height': thumbnail.get('height')
        } for thumbnail in traverse_obj(product_media, ('image_versions2', 'candidates')) or []]
        return {
            'id': media_id,
            'duration': float_or_none(product_media.get('video_duration')),
            'formats': formats,
            'thumbnails': thumbnails
        }

    def _extract_product(self, product_info):
        if isinstance(product_info, list):
            product_info = product_info[0]

        comment_data = traverse_obj(product_info, ('edge_media_to_parent_comment', 'edges'), ('comments'))
        comments = [{
            'author': traverse_obj(comment_dict, ('node', 'owner', 'username'), ('user', 'username')),
            'author_id': traverse_obj(comment_dict, ('node', 'owner', 'id'), ('user', 'pk')),
            'id': traverse_obj(comment_dict, ('node', 'id'), ('pk')),
            'text': traverse_obj(comment_dict, ('node', 'text'), ('text')),
            'timestamp': traverse_obj(comment_dict, ('node', 'created_at'), ('created_at'), expected_type=int_or_none),
        } for comment_dict in comment_data] if comment_data else None

        user_info = product_info.get('user') or {}
        info_dict = {
            'id': product_info.get('code') or _pk_to_id(product_info.get('pk')),
            'title': product_info.get('title') or f'Video by {user_info.get("username")}',
            'description': traverse_obj(product_info, ('caption', 'text'), expected_type=str_or_none),
            'timestamp': int_or_none(product_info.get('taken_at')),
            'channel': user_info.get('username'),
            'uploader': user_info.get('full_name'),
            'uploader_id': str_or_none(user_info.get('pk')),
            'view_count': int_or_none(product_info.get('view_count')),
            'like_count': int_or_none(product_info.get('like_count')),
            'comment_count': int_or_none(product_info.get('comment_count')),
            'comments': comments,
            'http_headers': {
                'Referer': 'https://www.instagram.com/',
            }
        }

Review comment (suggestion):
```suggestion
        comment_data = traverse_obj(product_info, ('edge_media_to_parent_comment', 'edges'), 'comments')
```

Code after:
            'url': format.get('url'),
            'width': format.get('width'),
            'height': format.get('height'),
            'vcodec': vcodec,
        } for format in videos_list or []]
        if dash_manifest_raw:
            formats.extend(self._parse_mpd_formats(self._parse_xml(dash_manifest_raw, media_id), mpd_id='dash'))
        self._sort_formats(formats)

        thumbnails = [{
            'url': thumbnail.get('url'),
            'width': thumbnail.get('width'),
            'height': thumbnail.get('height')
        } for thumbnail in traverse_obj(product_media, ('image_versions2', 'candidates')) or []]
        return {
            'id': media_id,
            'duration': float_or_none(product_media.get('video_duration')),
            'formats': formats,
            'thumbnails': thumbnails
        }

    def _extract_product(self, product_info):
        if isinstance(product_info, list):
            product_info = product_info[0]

        user_info = product_info.get('user') or {}
        info_dict = {
            'id': _pk_to_id(traverse_obj(product_info, 'pk', 'id', expected_type=str_or_none)[:19]),
            'title': product_info.get('title') or f'Video by {user_info.get("username")}',
            'description': traverse_obj(product_info, ('caption', 'text'), expected_type=str_or_none),
            'timestamp': int_or_none(product_info.get('taken_at')),
            'channel': user_info.get('username'),
            'uploader': user_info.get('full_name'),
            'uploader_id': str_or_none(user_info.get('pk')),
            'view_count': int_or_none(product_info.get('view_count')),
            'like_count': int_or_none(product_info.get('like_count')),
            'comment_count': int_or_none(product_info.get('comment_count')),
            '__post_extractor': self.extract_comments(_pk_to_id(product_info.get('pk'))),
            'http_headers': {
                'Referer': 'https://www.instagram.com/',
            }
        }
        carousel_media = product_info.get('carousel_media')
        if carousel_media:
            return {
                '_type': 'playlist',
                **info_dict,
                'title': f'Post by {user_info.get("username")}',
                'entries': [{
                    **info_dict,
                    **self._extract_product_media(product_media),