diff --git a/docs/configuration.rst b/docs/configuration.rst index 50e40f70..d9edf5e0 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1843,6 +1843,16 @@ Description and adjust their filename extensions if they do not match. +downloader.http.headers +----------------------- +Type + ``object`` +Example + ``{"Accept": "image/webp,*/*", "Referer": "https://example.org/"}`` +Description + Additional HTTP headers to send when downloading files, + + downloader.ytdl.format ---------------------- Type diff --git a/gallery_dl/downloader/http.py b/gallery_dl/downloader/http.py index 8d72dc27..b08aae15 100644 --- a/gallery_dl/downloader/http.py +++ b/gallery_dl/downloader/http.py @@ -31,6 +31,7 @@ class HttpDownloader(DownloaderBase): self.downloading = False self.adjust_extension = self.config("adjust-extensions", True) + self.headers = self.config("headers") self.minsize = self.config("filesize-min") self.maxsize = self.config("filesize-max") self.retries = self.config("retries", extractor._retries) @@ -100,6 +101,9 @@ class HttpDownloader(DownloaderBase): file_size = pathfmt.part_size() if file_size: headers["Range"] = "bytes={}-".format(file_size) + # general headers + if self.headers: + headers.update(self.headers) # file-specific headers extra = pathfmt.kwdict.get("_http_headers") if extra: