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

Code before:
                }, note=f'Downloading {media_typ} stream data',
                impersonate=self._IMPERSONATE_TARGET)

            path_template = traverse_obj(stream, ('resource', 'uri', {str}))

            def format_path(params):
                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}))))
                formats.append({
                    **traverse_obj(quality, {
                        'format_id': ('name', {str}),
                        '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'),
                })

            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}),
                'description': ('text', {clean_html}),
                'like_count': ('likes', {int_or_none}),
                'dislike_count': ('dislikes', {int_or_none}),
                'comment_count': ('comments', {int_or_none}),
                'thumbnail': ('thumbnail', 'path', {url_or_none}),
            }),
            'http_headers': self._HEADERS,

Review comment (bug):
```suggestion
                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=' '))
                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,
                })
```

Code after:
                }, note=f'Downloading {media_typ} stream data',
                impersonate=self._IMPERSONATE_TARGET)

            path_template = traverse_obj(stream, ('resource', 'uri', {str}))

            def format_path(params):
                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,