From 45f364e09e0419cfab3e274805a4e51569e7a642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 3 Oct 2025 16:48:10 +0200 Subject: [PATCH] [dl:http] add MIME type and signature for m3u8 & mpd files (#8339) --- gallery_dl/downloader/http.py | 8 +++++++- test/test_downloader.py | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gallery_dl/downloader/http.py b/gallery_dl/downloader/http.py index 111fd9ba..248bf70f 100644 --- a/gallery_dl/downloader/http.py +++ b/gallery_dl/downloader/http.py @@ -413,7 +413,7 @@ class HttpDownloader(DownloaderBase): def _find_extension(self, response): """Get filename extension from MIME type""" mtype = response.headers.get("Content-Type", "image/jpeg") - mtype = mtype.partition(";")[0] + mtype = mtype.partition(";")[0].lower() if "/" not in mtype: mtype = "image/" + mtype @@ -475,6 +475,10 @@ MIME_TYPES = { "audio/ogg" : "ogg", "audio/mpeg" : "mp3", + "application/vnd.apple.mpegurl": "m3u8", + "application/x-mpegurl" : "m3u8", + "application/dash+xml" : "mpd", + "application/zip" : "zip", "application/x-zip": "zip", "application/x-zip-compressed": "zip", @@ -526,6 +530,8 @@ SIGNATURE_CHECKS = { s[8:12] == b"WAVE"), "mp3" : lambda s: (s[0:3] == b"ID3" or s[0:2] in (b"\xFF\xFB", b"\xFF\xF3", b"\xFF\xF2")), + "m3u8": lambda s: s[0:7] == b"#EXTM3U", + "mpd" : lambda s: b"