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

Code before:
        'only_matching': True,
    }, {
        # poll2choice_video card
        'url': 'https://twitter.com/CAF_Online/status/1349365911120195585',
        'only_matching': True,
    }, {
        # poll3choice_video card
        'url': 'https://twitter.com/SamsungMobileSA/status/1348609186725289984',
        'only_matching': True,
    }, {
        # poll4choice_video card
        'url': 'https://twitter.com/SouthamptonFC/status/1347577658079641604',
        'only_matching': True,
    }]

    def _graphql_to_legacy(self, data, twid):
        result = traverse_obj(data, (
            'threaded_conversation_with_injections_v2', 'instructions', 0, 'entries',
            lambda _, v: v['entryId'] == f'tweet-{twid}', 'content', 'itemContent',
            'tweet_results', 'result'
        ), expected_type=dict, default={}, get_all=False)

        # sometimes actual tweet might also be wrapped in "TweetWithVisibilityResults"
        # https://twitter.com/TaylorLorenz/status/1616319245847265280
        if result.get('tweet'):
            result = result['tweet']

        if result.get('__typename') not in ('Tweet', None):
            self.report_warning(f'Unknown typename: {result.get("__typename")}', twid, only_once=True)

        if 'tombstone' in result:
            cause = traverse_obj(result, ('tombstone', 'text', 'text'), expected_type=str)
            raise ExtractorError(f'Twitter API says: {cause or "Unknown error"}', expected=True)

        status = result.get('legacy', {})
        status.update(traverse_obj(result, {
            'user': ('core', 'user_results', 'result', 'legacy'),
            'card': ('card', 'legacy'),
            'quoted_status': ('quoted_status_result', 'result', 'legacy'),
        }, expected_type=dict, default={}))

        # extra transformation is needed since result does not match legacy format
        binding_values = {
            binding_value.get('key'): binding_value.get('value')
            for binding_value in traverse_obj(status, ('card', 'binding_values', ...), expected_type=dict)
        }
        if binding_values:
            status['card']['binding_values'] = binding_values

        return status


Review comment (suggestion):
```suggestion
            'tweet_results', 'result', ('tweet', None)
        ), expected_type=dict, default={}, get_all=False)
```
Add the commented URL as a test

Code after:
    }, {
        # onion route
        'url': 'https://twitter3e4tixl4xyajtrzo62zg5vztmjuricljdp2c5kshju4avyoid.onion/TwitterBlue/status/1484226494708662273',
        'only_matching': True,
    }, {
        # Twitch Clip Embed
        'url': 'https://twitter.com/GunB1g/status/1163218564784017422',
        'only_matching': True,
    }, {
        # promo_video_website card
        'url': 'https://twitter.com/GunB1g/status/1163218564784017422',
        'only_matching': True,
    }, {
        # promo_video_convo card
        'url': 'https://twitter.com/poco_dandy/status/1047395834013384704',
        'only_matching': True,
    }, {
        # appplayer card
        'url': 'https://twitter.com/poco_dandy/status/1150646424461176832',
        'only_matching': True,
    }, {
        # video_direct_message card
        'url': 'https://twitter.com/qarev001/status/1348948114569269251',
        'only_matching': True,
    }, {
        # poll2choice_video card
        'url': 'https://twitter.com/CAF_Online/status/1349365911120195585',
        'only_matching': True,
    }, {
        # poll3choice_video card
        'url': 'https://twitter.com/SamsungMobileSA/status/1348609186725289984',
        'only_matching': True,
    }, {
        # poll4choice_video card
        'url': 'https://twitter.com/SouthamptonFC/status/1347577658079641604',
        'only_matching': True,
    }]

    def _graphql_to_legacy(self, data, twid):
        result = traverse_obj(data, (
            'threaded_conversation_with_injections_v2', 'instructions', 0, 'entries',
            lambda _, v: v['entryId'] == f'tweet-{twid}', 'content', 'itemContent',
            'tweet_results', 'result', ('tweet', None),
        ), expected_type=dict, default={}, get_all=False)

        if result.get('__typename') not in ('Tweet', None):
            self.report_warning(f'Unknown typename: {result.get("__typename")}', twid, only_once=True)

        if 'tombstone' in result:
            cause = traverse_obj(result, ('tombstone', 'text', 'text'), expected_type=str)
            raise ExtractorError(f'Twitter API says: {cause or "Unknown error"}', expected=True)