diff --git a/README.md b/README.md index 12f68e98d8..40388e2628 100644 --- a/README.md +++ b/README.md @@ -785,6 +785,7 @@ Tip: Use `CTRL`+`F` (or `Command`+`F`) to search by keywords --add-headers FIELD:VALUE Specify a custom HTTP header and its value, separated by a colon ":". You can use this option multiple times + --no-std-headers Suppress standard headers --bidi-workaround Work around terminals that lack bidirectional text support. Requires bidiv or fribidi executable in PATH diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index a9f347bf4a..e63d634594 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -360,6 +360,7 @@ class YoutubeDL: (Only supported by some extractors) enable_file_urls: Enable file:// URLs. This is disabled by default for security reasons. http_headers: A dictionary of custom headers to be used for all requests + no_std_headers: Suppress standard headers proxy: URL of the proxy server to use geo_verification_proxy: URL of the proxy to use for IP address verification on geo-restricted sites. @@ -732,7 +733,8 @@ class YoutubeDL: raise self.params['compat_opts'] = set(self.params.get('compat_opts', ())) - self.params['http_headers'] = HTTPHeaderDict(std_headers, self.params.get('http_headers')) + headers = HTTPHeaderDict({}) if self.params.get('no_std_headers') else std_headers + self.params['http_headers'] = HTTPHeaderDict(headers, self.params.get('http_headers')) self._load_cookies(self.params['http_headers'].get('Cookie')) # compat self.params['http_headers'].pop('Cookie', None) diff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.py index 2e7646b7ec..510abbf63e 100644 --- a/yt_dlp/__init__.py +++ b/yt_dlp/__init__.py @@ -925,6 +925,7 @@ def parse_options(argv=None): 'prefer_insecure': opts.prefer_insecure, 'enable_file_urls': opts.enable_file_urls, 'http_headers': opts.headers, + 'no_std_headers': opts.no_std_headers, 'proxy': opts.proxy, 'socket_timeout': opts.socket_timeout, 'bidi_workaround': opts.bidi_workaround, diff --git a/yt_dlp/options.py b/yt_dlp/options.py index 13ba445df3..59aee0898d 100644 --- a/yt_dlp/options.py +++ b/yt_dlp/options.py @@ -1169,6 +1169,11 @@ def create_parser(): callback_kwargs={'multiple_keys': False}, help='Specify a custom HTTP header and its value, separated by a colon ":". You can use this option multiple times', ) + workarounds.add_option( + '--no-std-headers', + action='store_true', dest='no_std_headers', default=False, + help='Suppress standard headers', + ) workarounds.add_option( '--bidi-workaround', dest='bidi_workaround', action='store_true',