From b3b30a4bca45bd99c59475c2b4da88f95b646576 Mon Sep 17 00:00:00 2001 From: shirt-dev <2660574+shirt-dev@users.noreply.github.com> Date: Mon, 1 Mar 2021 12:05:45 -0500 Subject: [PATCH] Fix HLS playlist downloading (#127) Co-authored-by: shirtjs <2660574+shirtjs@users.noreply.github.com> --- yt_dlp/extractor/common.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index 45bc229ff2..edfc5a7823 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -1904,15 +1904,16 @@ def _parse_m3u8_formats(self, m3u8_doc, m3u8_url, ext=None, # media playlist and MUST NOT appear in master playlist thus we can # clearly detect media playlist with this criterion. - def _extract_m3u8_playlist_formats(format_url=None, m3u8_doc=None): + def _extract_m3u8_playlist_formats(format_url=None, m3u8_doc=None, video_id=None, + fatal=True, data=None, headers={}): if not m3u8_doc: if not format_url: return [] res = self._download_webpage_handle( format_url, video_id, note=False, - errnote=errnote or 'Failed to download m3u8 playlist information', - fatal=fatal, data=data, headers=headers, query=query) + errnote='Failed to download m3u8 playlist information', + fatal=fatal, data=data, headers=headers) if res is False: return [] @@ -1984,7 +1985,8 @@ def extract_media(x_media_line): if media_url: manifest_url = format_url(media_url) format_id = [] - playlist_formats = _extract_m3u8_playlist_formats(manifest_url) + playlist_formats = _extract_m3u8_playlist_formats(manifest_url, video_id=video_id, + fatal=fatal, data=data, headers=headers) for format in playlist_formats: format_index = format.get('index') @@ -2045,7 +2047,8 @@ def build_stream_name(): or last_stream_inf.get('BANDWIDTH'), scale=1000) manifest_url = format_url(line.strip()) - playlist_formats = _extract_m3u8_playlist_formats(manifest_url) + playlist_formats = _extract_m3u8_playlist_formats(manifest_url, video_id=video_id, + fatal=fatal, data=data, headers=headers) for format in playlist_formats: format_id = []