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

Code before:

                # If we need impersonation for the API, then we need it for HLS keys too: extract in advance
                if self._IMPERSONATE_TARGET is not None:
                    m3u8_data = self._download_webpage(
                        url, media_id, fatal=False, impersonate=self._IMPERSONATE_TARGET, headers=self._HEADERS,
                        note=join_nonempty('Downloading', format_id, 'm3u8 information', delim=' '),
                        errnote=join_nonempty('Failed to download', format_id, 'm3u8 information', delim=' '))
                    if not m3u8_data:
                        continue

                    key_url = self._search_regex(
                        r'#EXT-X-KEY:METHOD=AES-128,URI="(https?://[^"]+)"',
                        m3u8_data, 'HLS AES key URI', default=None)
                    if key_url:
                        urlh = self._request_webpage(
                            key_url, media_id, fatal=False, impersonate=self._IMPERSONATE_TARGET, headers=self._HEADERS,
                            note=join_nonempty('Downloading', format_id, 'HLS AES key', delim=' '),
                            errnote=join_nonempty('Failed to download', format_id, 'HLS AES key', delim=' '))
                        if urlh:
                            hls_aes['key'] = urlh.read().hex()

                formats.append({
                    **traverse_obj(variant, {
                        'format_note': ('label', {str}),
                        'width': ('meta', 'video', 'width', {int}),
                        'height': ('meta', 'video', 'height', {int}),
                    }),
                    **parse_codecs(traverse_obj(variant, ('meta', 'video', 'codec', {str}))),
                    'url': url,
                    'ext': determine_ext(url.partition('/chunk.m3u8')[0], 'mp4'),
                    'format_id': format_id,
                    'hls_media_playlist_data': m3u8_data,
                    'hls_aes': hls_aes or None,
                })
            items.append({
                **common_info,
                'id': media_id,
                **traverse_obj(metadata, {
                    'title': ('title', {str}),
                    'duration': ('duration', {int_or_none}),
                    'thumbnail': ('thumbnail', 'path', {url_or_none}),
                }),
                'formats': formats,
            })

        post_info = {
            **common_info,
            'id': post_id,
            'display_id': post_id,
            **traverse_obj(post_data, {
                'title': ('title', {str}),

Review comment (suggestion):
Instead, as they provide much more info now, we can do the following:
```suggestion
                        'width': ('meta', 'video', 'width', {int_or_none}),
                        'height': ('meta', 'video', 'height', {int_or_none}),
                        'vcodec': ('meta', 'video', 'codec', {str}),
                        'acodec': ('meta', 'audio', 'codec', {str}),
                        'vbr': ('meta', 'video', 'bitrate', 'average', {int_or_none(scale=1000)}),
                        'abr': ('meta', 'audio', 'bitrate', 'average', {int_or_none(scale=1000)}),
                        'audio_channels': ('meta', 'audio', 'channelCount', {int_or_none}),
                        'fps': ('meta', 'video', 'fps', {float_or_none}),
```

Code after:
                hls_aes = {}
                m3u8_data = None

                # If we need impersonation for the API, then we need it for HLS keys too: extract in advance
                if self._IMPERSONATE_TARGET is not None:
                    m3u8_data = self._download_webpage(
                        format_url, media_id, fatal=False, impersonate=self._IMPERSONATE_TARGET, headers=self._HEADERS,
                        note=join_nonempty('Downloading', format_id, 'm3u8 information', delim=' '),
                        errnote=join_nonempty('Failed to download', format_id, 'm3u8 information', delim=' '))
                    if not m3u8_data:
                        continue

                    key_url = self._search_regex(
                        r'#EXT-X-KEY:METHOD=AES-128,URI="(https?://[^"]+)"',
                        m3u8_data, 'HLS AES key URI', default=None)
                    if key_url:
                        urlh = self._request_webpage(
                            key_url, media_id, fatal=False, impersonate=self._IMPERSONATE_TARGET, headers=self._HEADERS,
                            note=join_nonempty('Downloading', format_id, 'HLS AES key', delim=' '),
                            errnote=join_nonempty('Failed to download', format_id, 'HLS AES key', delim=' '))
                        if urlh:
                            hls_aes['key'] = urlh.read().hex()

                formats.append({
                    **traverse_obj(variant, {
                        'format_note': ('label', {str}),
                        'width': ('meta', 'video', 'width', {int_or_none}),
                        'height': ('meta', 'video', 'height', {int_or_none}),
                        'vcodec': ('meta', 'video', 'codec', {str}),
                        'acodec': ('meta', 'audio', 'codec', {str}),
                        'vbr': ('meta', 'video', 'bitrate', 'average', {int_or_none(scale=1000)}),
                        'abr': ('meta', 'audio', 'bitrate', 'average', {int_or_none(scale=1000)}),
                        'audio_channels': ('meta', 'audio', 'channelCount', {int_or_none}),
                        'fps': ('meta', 'video', 'fps', {float_or_none}),
                    }),
                    'url': format_url,
                    'ext': determine_ext(format_url.partition('/chunk.m3u8')[0], 'mp4'),
                    'format_id': format_id,
                    'hls_media_playlist_data': m3u8_data,
                    'hls_aes': hls_aes or None,
                })
            items.append({
                **common_info,
                'id': media_id,
                **traverse_obj(metadata, {
                    'title': ('title', {str}),
                    'duration': ('duration', {int_or_none}),
                    'thumbnail': ('thumbnail', 'path', {url_or_none}),
                }),
                'formats': formats,
            })