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

Code before:

        if self.get_param('ignore_no_formats_error'):
            fatal = False

        if not m3u8_url:
            if errnote is not False:
                errnote = errnote or 'Failed to obtain m3u8 URL'
                if fatal:
                    raise ExtractorError(errnote, video_id=video_id)
                self.report_warning(f'{errnote}{bug_reports_message()}')
            return [], {}
        if note is None:
            note = 'Downloading m3u8 information'
        if errnote is None:
            errnote = 'Failed to download m3u8 information'
        response = self._request_webpage(
            m3u8_url, video_id, note=note, errnote=errnote,
            fatal=fatal, data=data, headers=headers, query=query)
        if response is False:
            return [], {}

        with contextlib.closing(response):
            prefix = response.read(512)
            if not prefix.startswith(b'#EXTM3U'):
                self.report_warning(f'{video_id}: Trying to parse m3u8 without header{bug_reports_message()}')
                return [], {}

            content = self._webpage_read_content(
                response, m3u8_url, video_id, note=note, errnote=errnote,
                fatal=fatal, prefix=prefix, data=data)
        if content is False:
            return [], {}

        return self._parse_m3u8_formats_and_subtitles(
            content, response.url, ext=ext, entry_protocol=entry_protocol,
            preference=preference, quality=quality, m3u8_id=m3u8_id,
            note=note, errnote=errnote, fatal=fatal, live=live, data=data,
            headers=headers, query=query, video_id=video_id)

    def _parse_m3u8_formats_and_subtitles(
            self, m3u8_doc, m3u8_url=None, ext=None, entry_protocol='m3u8_native',
            preference=None, quality=None, m3u8_id=None, live=False, note=None,
            errnote=None, fatal=True, data=None, headers={}, query={},
            video_id=None):
        formats, subtitles = [], {}
        has_drm = HlsFD._has_drm(m3u8_doc)

        def format_url(url):
            return url if re.match(r'https?://', url) else urllib.parse.urljoin(m3u8_url, url)

        if self.get_param('hls_split_discontinuity', False):

Review comment (bug):
```suggestion
                msg = 'Response data has no m3u header'
                if fatal:
                    raise ExtractorError(msg, video_id=video_id)
                self.report_warning(bug_reports_message(f'{msg}; '), video_id=video_id)
                return [], {}
```

Code after:

        if self.get_param('ignore_no_formats_error'):
            fatal = False

        if not m3u8_url:
            if errnote is not False:
                errnote = errnote or 'Failed to obtain m3u8 URL'
                if fatal:
                    raise ExtractorError(errnote, video_id=video_id)
                self.report_warning(f'{errnote}{bug_reports_message()}')
            return [], {}
        if note is None:
            note = 'Downloading m3u8 information'
        if errnote is None:
            errnote = 'Failed to download m3u8 information'
        response = self._request_webpage(
            m3u8_url, video_id, note=note, errnote=errnote,
            fatal=fatal, data=data, headers=headers, query=query)
        if response is False:
            return [], {}

        with contextlib.closing(response):
            prefix = response.read(512)
            if not prefix.startswith(b'#EXTM3U'):
                msg = 'Response data has no m3u header'
                if fatal:
                    raise ExtractorError(msg, video_id=video_id)
                self.report_warning(f'{msg}{bug_reports_message()}', video_id=video_id)
                return [], {}

            content = self._webpage_read_content(
                response, m3u8_url, video_id, note=note, errnote=errnote,
                fatal=fatal, prefix=prefix, data=data)
        if content is False:
            return [], {}

        return self._parse_m3u8_formats_and_subtitles(
            content, response.url, ext=ext, entry_protocol=entry_protocol,
            preference=preference, quality=quality, m3u8_id=m3u8_id,
            note=note, errnote=errnote, fatal=fatal, live=live, data=data,
            headers=headers, query=query, video_id=video_id)

    def _parse_m3u8_formats_and_subtitles(
            self, m3u8_doc, m3u8_url=None, ext=None, entry_protocol='m3u8_native',
            preference=None, quality=None, m3u8_id=None, live=False, note=None,
            errnote=None, fatal=True, data=None, headers={}, query={},
            video_id=None):
        formats, subtitles = [], {}
        has_drm = HlsFD._has_drm(m3u8_doc)

        def format_url(url):