Fix HLS playlist downloading (#127)

Co-authored-by: shirtjs <2660574+shirtjs@users.noreply.github.com>
This commit is contained in:
shirt-dev 2021-03-01 12:05:45 -05:00 committed by GitHub
parent 5372545ddb
commit b3b30a4bca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 # media playlist and MUST NOT appear in master playlist thus we can
# clearly detect media playlist with this criterion. # 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 m3u8_doc:
if not format_url: if not format_url:
return [] return []
res = self._download_webpage_handle( res = self._download_webpage_handle(
format_url, video_id, format_url, video_id,
note=False, note=False,
errnote=errnote or 'Failed to download m3u8 playlist information', errnote='Failed to download m3u8 playlist information',
fatal=fatal, data=data, headers=headers, query=query) fatal=fatal, data=data, headers=headers)
if res is False: if res is False:
return [] return []
@ -1984,7 +1985,8 @@ def extract_media(x_media_line):
if media_url: if media_url:
manifest_url = format_url(media_url) manifest_url = format_url(media_url)
format_id = [] 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: for format in playlist_formats:
format_index = format.get('index') format_index = format.get('index')
@ -2045,7 +2047,8 @@ def build_stream_name():
or last_stream_inf.get('BANDWIDTH'), scale=1000) or last_stream_inf.get('BANDWIDTH'), scale=1000)
manifest_url = format_url(line.strip()) 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: for format in playlist_formats:
format_id = [] format_id = []