1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

[downloader:http] add 'headers' option (#1322)

This commit is contained in:
Mike Fährmann 2021-02-21 19:13:39 +01:00
parent 6b0ecbf6bc
commit 560277394e
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 14 additions and 0 deletions

View File

@ -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

View File

@ -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: