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

Code before:
                path = path_template
                for i, val in (params or {}).items():
                    path = path.replace(f'{{qualityLevelParams.{i}}}', val)
                return path

            formats = []
            for quality in traverse_obj(stream, ('resource', 'data', 'qualityLevels', ...)):
                url = urljoin(stream['cdn'], format_path(traverse_obj(
                    stream, ('resource', 'data', 'qualityLevelParams', quality['name'], {dict}))))
                format_id = traverse_obj(quality, ('name', {str}))

                m3u8_data = self._download_webpage(
                    url, media_id, fatal=False, impersonate=self._IMPERSONATE_TARGET,
                    note=join_nonempty('Downloading', format_id, 'm3u8 information', delim=' '),
                    errnote=join_nonempty('Failed to download', format_id, 'm3u8 information', delim=' '), headers=self._HEADERS)
                if not m3u8_data:
                    continue
                hls_aes = {}
                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,
                        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(quality, {
                        'format_note': ('label', {str}),
                        'width': ('width', {int}),
                        'height': ('height', {int}),
                    }),
                    **parse_codecs(quality.get('codecs')),
                    '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,

Review comment (bug):
we don't need to add the headers here? (if you want to add them, please test if they're harmful first)
```suggestion
                    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=' '),
```

Code after:
                path = path_template
                for i, val in (params or {}).items():
                    path = path.replace(f'{{qualityLevelParams.{i}}}', val)
                return path

            formats = []
            for quality in traverse_obj(stream, ('resource', 'data', 'qualityLevels', ...)):
                url = urljoin(stream['cdn'], format_path(traverse_obj(
                    stream, ('resource', 'data', 'qualityLevelParams', quality['name'], {dict}))))
                format_id = traverse_obj(quality, ('name', {str}))
                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(
                        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(quality, {
                        'format_note': ('label', {str}),
                        'width': ('width', {int}),
                        'height': ('height', {int}),
                    }),
                    **parse_codecs(quality.get('codecs')),
                    '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}),