From 483e30d846f84e7ece72c5f15b61bc571cf3835a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 7 Jun 2025 22:01:07 +0200 Subject: [PATCH] [dl:http] allow '_http_signature' to return a custom error message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … and fail the download immediately like '_http_validate' --- gallery_dl/downloader/http.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gallery_dl/downloader/http.py b/gallery_dl/downloader/http.py index 531940fd..c37c8f50 100644 --- a/gallery_dl/downloader/http.py +++ b/gallery_dl/downloader/http.py @@ -280,9 +280,13 @@ class HttpDownloader(DownloaderBase): except (RequestException, SSLError) as exc: msg = str(exc) continue - if validate_sig and not validate_sig(file_header): - msg = "Invalid file signature bytes" - continue + if validate_sig: + result = validate_sig(file_header) + if result is not True: + self.release_conn(response) + self.log.warning( + result or "Invalid file signature bytes") + return False if validate_ext and self._adjust_extension( pathfmt, file_header) and pathfmt.exists(): pathfmt.temppath = ""