From c0d7d2be3526ce547ebdce62a25ca9b5f09f1e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 11 Jan 2023 15:37:40 +0100 Subject: [PATCH] [downloader:http] add 'validate' option --- docs/configuration.rst | 13 +++++++++++++ docs/gallery-dl.conf | 3 ++- gallery_dl/downloader/http.py | 5 +++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 3f0744cd..6ae9e419 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -3466,6 +3466,19 @@ Description regardless of this option. +downloader.http.validate +------------------------ +Type + ``bool`` +Default + ``true`` +Description + Check for invalid responses. + + Fail a download when a file does not pass + instead of downloading a potentially broken file. + + downloader.ytdl.format ---------------------- Type diff --git a/docs/gallery-dl.conf b/docs/gallery-dl.conf index 2d2adbb7..3012e71f 100644 --- a/docs/gallery-dl.conf +++ b/docs/gallery-dl.conf @@ -390,7 +390,8 @@ { "adjust-extensions": true, "chunk-size": 32768, - "headers": null + "headers": null, + "validate": true }, "ytdl": diff --git a/gallery_dl/downloader/http.py b/gallery_dl/downloader/http.py index 40374201..0bf19c2e 100644 --- a/gallery_dl/downloader/http.py +++ b/gallery_dl/downloader/http.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2014-2022 Mike Fährmann +# Copyright 2014-2023 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -33,6 +33,7 @@ class HttpDownloader(DownloaderBase): self.chunk_size = self.config("chunk-size", 32768) self.metadata = extractor.config("http-metadata") self.progress = self.config("progress", 3.0) + self.validate = self.config("validate", True) self.headers = self.config("headers") self.minsize = self.config("filesize-min") self.maxsize = self.config("filesize-max") @@ -175,7 +176,7 @@ class HttpDownloader(DownloaderBase): # check for invalid responses validate = kwdict.get("_http_validate") - if validate: + if validate and self.validate: result = validate(response) if isinstance(result, str): url = result