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

Code before:
            'author_url': f'https://bsky.app/profile/{author_handle}',
            'author_is_uploader': 'Yes' if author_did in root_uri else 'No',
        }]

        if replies := thread_node.get('replies'):
            for reply in replies:
                formatted_comments.extend(self.traverse_replies(reply, root_uri))
        return formatted_comments

    def _real_extract(self, url):
        handle, video_id = self._match_valid_url(url).groups()
        did = self._download_json(
            'https://bsky.social/xrpc/com.atproto.identity.resolveHandle',
            video_id, query={'handle': handle}, expected_status=200).get('did')

        meta = self._download_json(
            'https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread',
            video_id, headers={'Content-Type': 'application/json'},
            query={'uri': f'at://{did}/app.bsky.feed.post/{video_id}',
                   'depth': 6 if self.get_param('write_comments') else 0, 'parentHeight': 0},
            expected_status=200)

        formats, subs = self._extract_m3u8_formats_and_subtitles(
            traverse_obj(meta, ('thread', 'post', 'embed', 'playlist')),
            video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False,
            note='Downloading HD m3u8 information', errnote='Unable to download HD m3u8 information')

        formatted_replies = self.traverse_replies(
            meta.get('thread'), (traverse_obj(meta, ('thread', 'post', 'record', 'reply', 'root', 'uri'))
                                 or traverse_obj(meta, ('thread', 'post', 'uri'))))

        uploader = traverse_obj(meta, ('thread', 'post', 'author', 'displayName'))
        description = traverse_obj(meta, ('thread', 'post', 'record', 'text'))

        return {
            'id': video_id,
            'title': f'{uploader}: {description}',
            'formats': formats,
            'description': description,
            'thumbnail': traverse_obj(meta, ('thread', 'post', 'embed', 'thumbnail'), expected_type=url_or_none),
            'alt-title': traverse_obj(meta, ('thread', 'post', 'record', 'alt'), ('thread', 'post', 'embed', 'alt')),
            'uploader': uploader,
            'channel': handle,
            'uploader_id': did,
            'channel_id': did,
            'uploader_url': f'https://bsky.app/profile/{handle}',
            'channel_url': f'https://bsky.app/profile/{handle}',
            'timestamp': parse_iso8601(traverse_obj(meta, ('thread', 'post', 'record', 'createdAt'))),
            'like_count': traverse_obj(meta, ('thread', 'post', 'likeCount')),
            'repost_count': traverse_obj(meta, ('thread', 'post', 'repostCount')),
            'comment_count': traverse_obj(meta, ('thread', 'post', 'replyCount')),

Review comment (refactor):
This does not extract the best available format.

For example, for https://bsky.app/profile/blu3blue.bsky.social/post/3l4omssdl632g the best format at 634x1080 resolution can be downloaded via
```
https://bsky.social/xrpc/com.atproto.sync.getBlob?did=did:plc:pzdr5ylumf7vmvwasrpr5bf2&cid=bafkreiamqpagnuwf72e5zj2xypoew3t2arxho4nse3le5l4zwou4hcrfne
```

See https://github.com/mikf/gallery-dl/commit/4c391805de49c7b7f1b98357c2bd0096a5e88fce or https://github.com/danbooru/danbooru/pull/5816/commits/dc37dd19ee23bddab34f3d4b9c707b8dd898871b

Code after:
            'duration': 321,
            'age_limit': 0,
            'like_count': int,
            'view_count': int,
            'comment_count': int,
            'channel_follower_count': int,
            'categories': ['Entertainment'],
            'tags': [],
        },
        'add_ie': ['Youtube'],
    }, {
        'url': 'https://bsky.app/profile/endshark.bsky.social/post/3jzxjkcemae2m',
        'info_dict': {
            'id': '222792849',
            'ext': 'mp3',
            'uploader': 'LASERBAT',
            'uploader_id': 'laserbatx',
            'uploader_url': 'https://laserbatx.bandcamp.com',
            'artists': ['LASERBAT'],
            'album_artists': ['LASERBAT'],
            'album': 'Hari Nezumi [EP]',
            'track': 'Forward to the End',
            'title': 'LASERBAT - Forward to the End',
            'thumbnail': 'https://f4.bcbits.com/img/a2507705510_5.jpg',
            'duration': 228.571,
            'track_id': '222792849',
            'release_date': '20230423',
            'upload_date': '20230423',
            'timestamp': 1682276040.0,
            'release_timestamp': 1682276040.0,
            'track_number': 1,
        },
        'add_ie': ['Bandcamp'],
    }, {
        'url': 'https://bsky.app/profile/dannybhoix.bsky.social/post/3l6oe5mtr2c2j',
        'md5': 'b9e344fdbce9f2852c668a97efefb105',
        'info_dict': {
            'id': '3l3vgf77uco2g',
            'ext': 'mp4',
            'uploader': 'Bluesky',
            'uploader_id': 'bsky.app',
            'uploader_url': 'https://bsky.app/profile/bsky.app',
            'channel_id': 'did:plc:z72i7hdynmk6r22z27h6tvur',
            'channel_url': 'https://bsky.app/profile/did:plc:z72i7hdynmk6r22z27h6tvur',
            'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$',
            'title': 'Bluesky now has video! Update your app to versi...',
            'alt_title': 'Bluesky video feature announcement',
            'description': r're:(?s)Bluesky now has video! .{239}',
            'upload_date': '20240911',
            'timestamp': 1726074716,
            'like_count': int,