Add content-type check for HLS responses
This commit is contained in:
parent
5674b4aa0d
commit
b13d4186b0
|
@ -29,11 +29,19 @@ from .model import Rendition, RenditionAudio, RenditionSubtitles, Source, Varian
|
|||
# the same file
|
||||
# - Subtitles indexes have only one segment
|
||||
|
||||
MIME_TYPE = "application/x-mpegURL"
|
||||
|
||||
|
||||
def _fetch_index(http_session, url):
|
||||
# Fetch a M3U8 playlist
|
||||
r = http_session.get(url)
|
||||
r.raise_for_status()
|
||||
|
||||
if (_ := r.headers["content-type"]) != MIME_TYPE:
|
||||
raise UnexpectedHLSResponse("MIME_TYPE", url, MIME_TYPE, _)
|
||||
|
||||
r.encoding = "utf-8"
|
||||
|
||||
return m3u8.loads(r.text, url)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue