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

Code before:
                'duration': 145.0,
                'timestamp': 1729137765.846,
                'upload_date': '20241017',
                'modified_timestamp': 1729138184.891,
                'modified_date': '20241017',
            },
            'params': {'format': 'direct'},
        }],
    }]

    def _real_extract(self, url):
        display_id = self._match_valid_url(url).group('display_id')
        webpage = self._download_webpage(url, display_id)
        app_id = traverse_obj(
            self._search_json(r'window\.env\s*=', webpage, 'window env', display_id, default={}),
            ('TOP_AUTH_SERVICE_APP_ID', {str}))

        entries = []
        for player_data in traverse_obj(webpage, (
                {find_elements(tag='div', attr='data-component-name', value='video-player', html=True)},
                ..., {extract_attributes}, all, lambda _, v: v['data-media-id'] and v['data-video-resource-parent-uri'])):
            media_id = player_data['data-media-id']
            parent_uri = player_data['data-video-resource-parent-uri']
            formats, subtitles = [], {}

            video_data = self._download_json(
                'https://fave.api.cnn.io/v1/video', media_id,
                query={
                    'id': media_id,
                    'stellarUri': parent_uri,
                })
            for direct_url in traverse_obj(video_data, ('files', ..., 'fileUri', {url_or_none})):
                resolution, bitrate = None, None
                if mobj := re.search(r'-(?P<res>\d+x\d+)_(?P<tbr>\d+)k\.mp4', direct_url):
                    resolution, bitrate = mobj.group('res', 'tbr')
                formats.append({
                    'url': direct_url,
                    'format_id': 'direct',
                    'quality': 1,
                    'tbr': int_or_none(bitrate),
                    **parse_resolution(resolution),
                })
            for sub_data in traverse_obj(video_data, (
                    'closedCaptions', 'types', lambda _, v: url_or_none(v['track']['url']), 'track')):
                subtitles.setdefault(sub_data.get('lang') or 'en', []).append({
                    'url': sub_data['url'],
                    'name': sub_data.get('label'),
                })

            if app_id:
                media_data = self._download_json(

Review comment (suggestion):
then we'd have to indent all of this, which is making me dislike my own idea
```suggestion
            if parent_uri:
                video_data = self._download_json(
```

Code after:
                'timestamp': 1729137765,
                'upload_date': '20241017',
                'modified_timestamp': 1729138184,
                'modified_date': '20241017',
            },
            'params': {'format': 'direct'},
        }],
    }]

    def _real_extract(self, url):
        display_id = self._match_valid_url(url).group('display_id')
        webpage = self._download_webpage(url, display_id)
        app_id = traverse_obj(
            self._search_json(r'window\.env\s*=', webpage, 'window env', display_id, default={}),
            ('TOP_AUTH_SERVICE_APP_ID', {str}))

        entries = []
        for player_data in traverse_obj(webpage, (
                {find_elements(tag='div', attr='data-component-name', value='video-player', html=True)},
                ..., {extract_attributes}, all, lambda _, v: v['data-media-id'])):
            media_id = player_data['data-media-id']
            parent_uri = player_data.get('data-video-resource-parent-uri')
            formats, subtitles = [], {}

            video_data = {}
            if parent_uri:
                video_data = self._download_json(
                    'https://fave.api.cnn.io/v1/video', media_id, fatal=False,
                    query={
                        'id': media_id,
                        'stellarUri': parent_uri,
                    })
                for direct_url in traverse_obj(video_data, ('files', ..., 'fileUri', {url_or_none})):
                    resolution, bitrate = None, None
                    if mobj := re.search(r'-(?P<res>\d+x\d+)_(?P<tbr>\d+)k\.mp4', direct_url):
                        resolution, bitrate = mobj.group('res', 'tbr')
                    formats.append({
                        'url': direct_url,
                        'format_id': 'direct',
                        'quality': 1,
                        'tbr': int_or_none(bitrate),
                        **parse_resolution(resolution),
                    })
                for sub_data in traverse_obj(video_data, (
                        'closedCaptions', 'types', lambda _, v: url_or_none(v['track']['url']), 'track')):
                    subtitles.setdefault(sub_data.get('lang') or 'en', []).append({
                        'url': sub_data['url'],
                        'name': sub_data.get('label'),
                    })

            if app_id: