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

Code before:
                raise ExtractorError(
                    '%s returned error: %s' % (self.IE_NAME, message), expected=True)

        hash_code = security_hash[:2]
        padding = '%010d' % random.randint(1, 10000000000)
        if hash_code in ('04', '14'):
            received_time = security_hash[3:13]
            received_md5 = security_hash[24:]
            hash_prefix = security_hash[:23]
        elif hash_code in ('02', '12', '03', '13'):
            received_time = security_hash[2:12]
            received_md5 = security_hash[22:]
            padding += '1'
            hash_prefix = '05' + security_hash[:22]

        padded_sign_time = compat_str(int(received_time) + 86400) + padding
        md5_data = (received_md5 + padded_sign_time + '0xAC10FD').encode()
        signed_md5 = base64.urlsafe_b64encode(hashlib.md5(md5_data).digest()).decode().strip('=')
        signed_hash = hash_prefix + padded_sign_time + signed_md5
        source = security['source']['url_parts']
        resource_url = source['scheme'] + '://' + source['domain'] + source['path']
        signed_url = '%s?h=%s&k=html5&a=%s' % (resource_url, signed_hash, 'F' if video.get('subscriber_only') else 'A')

        formats.extend(self._extract_m3u8_formats(
                       signed_url, video_id, 'mp4', entry_protocol='m3u8_native',
                       m3u8_id='hls', fatal=False))
        self._sort_formats(formats)

        subtitles = {}
        for resource in video['resources']:
            if resource.get('type') == 'subtitle':
                subtitles.setdefault(resource.get('language') or 'por', []).append({
                    'url': resource.get('url'),
                })
        for sub_lang, sub_url in try_get(security, lambda x: x['source']['subtitles'], expected_type=dict).items():
            if sub_url:
                subtitles.setdefault(sub_lang or 'por', []).append({
                    'url': sub_url,
                })
        for sub_lang, sub_url in try_get(security, lambda x: x['source']['subtitles_webvtt'], expected_type=dict).items():
            if sub_url:
                subtitles.setdefault(sub_lang or 'por', []).append({
                    'url': sub_url,
                })

        duration = float_or_none(video.get('duration'), 1000)
        uploader = video.get('channel')
        uploader_id = str_or_none(video.get('channel_id'))

        return {
            'id': video_id,

Review comment (refactor):
```suggestion
        formats.extend(self._extract_m3u8_formats(
            signed_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False))
```

The intends are confusing. The params are inside `_extract_m3u8_formats` but are aligned to the `formats.extend`. weird that flake8 doesnt catch this

Code after:
        security_hash = security['source']['token']
        if not security_hash:
            message = security.get('message')
            if message:
                raise ExtractorError(
                    '%s returned error: %s' % (self.IE_NAME, message), expected=True)

        hash_code = security_hash[:2]
        padding = '%010d' % random.randint(1, 10000000000)
        if hash_code in ('04', '14'):
            received_time = security_hash[3:13]
            received_md5 = security_hash[24:]
            hash_prefix = security_hash[:23]
        elif hash_code in ('02', '12', '03', '13'):
            received_time = security_hash[2:12]
            received_md5 = security_hash[22:]
            padding += '1'
            hash_prefix = '05' + security_hash[:22]

        padded_sign_time = compat_str(int(received_time) + 86400) + padding
        md5_data = (received_md5 + padded_sign_time + '0xAC10FD').encode()
        signed_md5 = base64.urlsafe_b64encode(hashlib.md5(md5_data).digest()).decode().strip('=')
        signed_hash = hash_prefix + padded_sign_time + signed_md5
        source = security['source']['url_parts']
        resource_url = source['scheme'] + '://' + source['domain'] + source['path']
        signed_url = '%s?h=%s&k=html5&a=%s' % (resource_url, signed_hash, 'F' if video.get('subscriber_only') else 'A')

        formats.extend(self._extract_m3u8_formats(
            signed_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False))
        self._sort_formats(formats)

        subtitles = {}
        for resource in video['resources']:
            if resource.get('type') == 'subtitle':
                subtitles.setdefault(resource.get('language') or 'por', []).append({
                    'url': resource.get('url'),
                })
        subs = try_get(security, lambda x: x['source']['subtitles'], expected_type=dict) or {}
        for sub_lang, sub_url in subs.items():
            if sub_url:
                subtitles.setdefault(sub_lang or 'por', []).append({
                    'url': sub_url,
                })
        subs = try_get(security, lambda x: x['source']['subtitles_webvtt'], expected_type=dict) or {}
        for sub_lang, sub_url in subs.items():
            if sub_url:
                subtitles.setdefault(sub_lang or 'por', []).append({
                    'url': sub_url,
                })

        duration = float_or_none(video.get('duration'), 1000)