From 115fd2c6f2afe2c3572dabe61903cb964615f833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 3 Mar 2020 21:21:57 +0100 Subject: [PATCH] "fix" incomplete MIME types (#632) e-/exhentai's original image downloads currently send incomplete/invalid Content-Type headers, "jpg" instead of "image/jpg" etc, since the last update. (https://forums.e-hentai.org/index.php?showtopic=236113) This change prepends any Content-Type value missing a media type specification with "image/", transforming it into a valid MIME type. (A global solution to a local problem, but it shouldn't cause any issues anywhere else) --- CHANGELOG.md | 2 ++ gallery_dl/downloader/http.py | 3 +++ gallery_dl/version.py | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1b8d6dc59..444bcba442 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## Unreleased + ## 1.13.1 - 2020-03-01 ### Additions - [hentaihand] add extractors ([#605](https://github.com/mikf/gallery-dl/issues/605)) diff --git a/gallery_dl/downloader/http.py b/gallery_dl/downloader/http.py index 7d4d7d59d7..844e422cb3 100644 --- a/gallery_dl/downloader/http.py +++ b/gallery_dl/downloader/http.py @@ -193,6 +193,9 @@ def get_extension(self, response): mtype = response.headers.get("Content-Type", "image/jpeg") mtype = mtype.partition(";")[0] + if "/" not in mtype: + mtype = "image/" + mtype + if mtype in MIMETYPE_MAP: return MIMETYPE_MAP[mtype] diff --git a/gallery_dl/version.py b/gallery_dl/version.py index 719595e306..6f3807b21f 100644 --- a/gallery_dl/version.py +++ b/gallery_dl/version.py @@ -6,4 +6,4 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. -__version__ = "1.13.1" +__version__ = "1.13.2-dev"