diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-01-29 03:25:35 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-03-04 20:59:03 +0530 |
commit | 8b7539d27c0a47d8d08e0522bdb66c571483377b (patch) | |
tree | 93327ca0c088d9a3e97878b52a8de4a49c897ac8 /yt_dlp/utils.py | |
parent | e48b3875ec4426ab9437fd06b857266d6e15bb55 (diff) | |
download | hypervideo-pre-8b7539d27c0a47d8d08e0522bdb66c571483377b.tar.lz hypervideo-pre-8b7539d27c0a47d8d08e0522bdb66c571483377b.tar.xz hypervideo-pre-8b7539d27c0a47d8d08e0522bdb66c571483377b.zip |
Implement `--add-header` without modifying `std_headers`
Closes #2526, #1614
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r-- | yt_dlp/utils.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index ef2c6bb24..be0c69d8f 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -1372,7 +1372,7 @@ class YoutubeDLHandler(compat_urllib_request.HTTPHandler): if url != url_escaped: req = update_Request(req, url=url_escaped) - for h, v in std_headers.items(): + for h, v in self._params.get('http_headers', std_headers).items(): # Capitalize is needed because of Python bug 2275: http://bugs.python.org/issue2275 # The dict keys are capitalized because of this bug by urllib if h.capitalize() not in req.headers: @@ -5436,3 +5436,8 @@ class WebSocketsWrapper(): has_websockets = bool(compat_websockets) + + +def merge_headers(*dicts): + """Merge dicts of network headers case insensitively, prioritizing the latter ones""" + return {k.capitalize(): v for k, v in itertools.chain.from_iterable(map(dict.items, dicts))} |