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

Code before:
                **traverse_obj(post, {
                    'text': ('record', 'text'),
                    'timestamp': ('record', 'createdAt', {parse_iso8601}),
                    'author': ('author', 'displayName'),
                    'author_thumbnail': ('author', 'avatar', {url_or_none}),
                }),
                'parent': 'root' if parent_uri == root_uri else parent_uri,
                'like_count': post.get('likeCount'),
                'author_id': author_did,
                'author_url': f'https://bsky.app/profile/{author_handle}',
                'author_is_uploader': author_did in root_uri,
            }
        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 get_service_endpoint(self, did, video_id):
        services = self._download_json(
            f'https://resolver.identity.foundation/1.0/identifiers/{did}',
            video_id, fatal=False).get('service') or []
        for service in services:
            if service.get('type') == 'AtprotoPersonalDataServer':
                return service.get('serviceEndpoint')
        return 'https://bsky.social'

    def _real_extract(self, url):
        handle, video_id = self._match_valid_url(url).groups()

        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://{handle}/app.bsky.feed.post/{video_id}',
                'depth': 1000 if getcomments else 0,
                'parentHeight': 1000 if getcomments else 0,
            })['thread']
        post = meta.get('post')

        did = traverse_obj(post, ('author', 'did'))
        record_embed = traverse_obj(post, ('record', 'embed', ('media', None)), get_all=False)
        post_type = record_embed.get('$type') if record_embed else None
        quoted_post = traverse_obj(post, ('embed', 'record', ('record', None)), get_all=False)
        quoted_type = traverse_obj(quoted_post, ('value', 'embed', ('media', None), '$type'), get_all=False)
        quoted_media = traverse_obj(quoted_post, ('embeds', 0, ('media', None)), get_all=False)

        if post_type == 'app.bsky.embed.external':
            return self.url_result(traverse_obj(
                post, ('embed', ('media', None), 'external', 'uri'), get_all=False)
                or traverse_obj(record_embed, ('external', 'uri')))

Review comment (suggestion):
`identity.foundation` is a third-party thing, right?
Might be better to just do this directly:
```suggestion
    def get_service_endpoint(self, did, video_id):
        if did.startswith('did:web:'):
            url = f'https://{did.split(":")[-1]}/.well-known/did.json'
        else:
            url = f'https://plc.directory/{did}'
        services = self._download_json(url, video_id, fatal=False)
        return traverse_obj(
            services, ('service', {lambda x: x.get('type') == 'AtprotoPersonalDataServer'},
                       'serviceEndpoint', {url_or_none}, any)) or 'https://bsky.social'
```

Code after:
        'info_dict': {
            'id': '3l7gv55dc2o2w',
        },
        'playlist': [{
            'info_dict': {
                'id': '3l7gv55dc2o2w',
                'ext': 'mp4',
                'upload_date': '20241026',
                'description': 'One of my favorite videos',
                'comment_count': int,
                'uploader_url': 'https://bsky.app/profile/purpleicetea.bsky.social',
                'uploader': 'Purple.Ice.Tea',
                'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$',
                'channel_url': 'https://bsky.app/profile/did:plc:bjh5ffwya5f53dfy47dezuwx',
                'like_count': int,
                'channel_id': 'did:plc:bjh5ffwya5f53dfy47dezuwx',
                'repost_count': int,
                'timestamp': 1729973202,
                'tags': [],
                'uploader_id': 'purpleicetea.bsky.social',
                'title': 'One of my favorite videos',
            },
        }, {
            'info_dict': {
                'id': '3l77u64l7le2e',
                'ext': 'mp4',
                'title': 'hearing people on twitter say that bluesky isn\'...',
                'like_count': int,
                'uploader_id': 'thafnine.net',
                'uploader_url': 'https://bsky.app/profile/thafnine.net',
                'upload_date': '20241024',
                'channel_url': 'https://bsky.app/profile/did:plc:6ttyq36rhiyed7wu3ws7dmqj',
                'description': r're:(?s)hearing people on twitter say that bluesky .{93}',
                'tags': [],
                'alt_title': 'md5:9b1ee1937fb3d1a81e932f9ec14d560e',
                'uploader': 'T9',
                'channel_id': 'did:plc:6ttyq36rhiyed7wu3ws7dmqj',
                'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$',
                'timestamp': 1729731642,
                'comment_count': int,
                'repost_count': int,
            },
        }],
    }]
    _BLOB_URL_TMPL = '{}/xrpc/com.atproto.sync.getBlob'

    def _get_service_endpoint(self, did, video_id):
        if did.startswith('did:web:'):
            url = f'https://{did[8:]}/.well-known/did.json'
        else:
            url = f'https://plc.directory/{did}'