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

Code before:
        if replies := thread_node.get('replies'):
            for reply in replies:
                yield from self.traverse_replies(reply, root_uri)
        if parent := thread_node.get('parent'):
            yield from self.traverse_replies(parent, root_uri)

    def _real_extract(self, url):
        handle, video_id = self._match_valid_url(url).groups()
        did = handle if handle.startswith('did:') else self._download_json(
            'https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle',
            video_id, query={'handle': handle}).get('did')

        getcomments = self.get_param('getcomments', False)
        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': 1000 if getcomments else 0,
                'parentHeight': 1000 if getcomments else 0,
            }).get('thread')
        post, record_embed = meta.get('post'), traverse_obj(meta, ('post', 'record', 'embed'))

        formats, subs = self._extract_m3u8_formats_and_subtitles(
            traverse_obj(post, ('embed', 'playlist'), ('embed', 'media', 'playlist')),
            video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False,
            note='Downloading HD m3u8 information', errnote='Unable to download HD m3u8 information')
        blob_cid = traverse_obj(record_embed, ('video', 'ref', '$link'), ('video', 'cid'),
                                ('media', 'video', 'ref', '$link'), ('media', 'video', 'cid'))
        if blob_cid:
            formats.append({
                'format_id': 'blob',
                'url': f'https://bsky.social/xrpc/com.atproto.sync.getBlob?did={did}&cid={blob_cid}',
                'ext': mimetype2ext(traverse_obj(record_embed, ('video', 'mimeType')), 'mp4'),
                'width': traverse_obj(record_embed, ('aspectRatio', 'width'), expected_type=int_or_none),
                'height': traverse_obj(record_embed, ('aspectRatio', 'height'), expected_type=int_or_none),
                'filesize': traverse_obj(record_embed, ('video', 'size'), expected_type=int_or_none),
            })

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

        return {
            'id': video_id,
            'title': f'{uploader}: "{description}"',
            'formats': formats,
            'description': description,
            'thumbnail': traverse_obj(post, ('embed', 'thumbnail'), expected_type=url_or_none),
            'alt_title': traverse_obj(post, ('embed', 'alt'), ('record', 'embed', 'alt')),
            'uploader': uploader,
            'channel': handle,

Review comment (bug):
You should differentiate between the different kinds of post response. This will break for posts with embeds such as `https://bsky.app/profile/yunayuispink.bsky.social/post/3l7gqcfes742o`
You also don't need to define the complete path always.
```py
traverse_obj(post, ('embed', 'playlist'), ('embed', 'media', 'playlist'))
```
can be simplified to
```py
traverse_obj(post, ('embed', ('media', None), 'playlist'))
```

Code after:
    }, {
        '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,
            'repost_count': int,
            'comment_count': int,
            'tags': [],
            'subtitles': {
                'en': 'mincount:1',
            },
        },
    }, {
        'url': 'https://bsky.app/profile/alt.bun.how/post/3l7rdfxhyds2f',
        'md5': '8775118b235cf9fa6b5ad30f95cda75c',
        'info_dict': {
            'id': '3l7rdfxhyds2f',
            'ext': 'mp4',
            'uploader': 'cinnamon',
            'uploader_id': 'alt.bun.how',
            'uploader_url': 'https://bsky.app/profile/alt.bun.how',
            'channel_id': 'did:plc:7x6rtuenkuvxq3zsvffp2ide',
            'channel_url': 'https://bsky.app/profile/did:plc:7x6rtuenkuvxq3zsvffp2ide',
            'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$',
            'title': 'crazy that i look like this tbh',
            'description': 'crazy that i look like this tbh',
            'upload_date': '20241030',
            'timestamp': 1730332128,
            'like_count': int,
            'repost_count': int,
            'comment_count': int,
            'tags': ['sexual'],
            'age_limit': 18,
        },
    }, {
        'url': 'at://did:plc:ia76kvnndjutgedggx2ibrem/app.bsky.feed.post/3l6zrz6zyl2dr',
        'md5': '71b0eb6d85d03145e6af6642c7fc6d78',
        'info_dict': {