mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-07 20:30:41 -05:00
Add --enable-file-urls
(#5917)
Closes https://github.com/yt-dlp/yt-dlp/issues/3675 Authored by: coletdjnz
This commit is contained in:
parent
d7f9871469
commit
8300774c4a
4 changed files with 15 additions and 3 deletions
|
@ -419,6 +419,8 @@ ## Network Options:
|
||||||
--source-address IP Client-side IP address to bind to
|
--source-address IP Client-side IP address to bind to
|
||||||
-4, --force-ipv4 Make all connections via IPv4
|
-4, --force-ipv4 Make all connections via IPv4
|
||||||
-6, --force-ipv6 Make all connections via IPv6
|
-6, --force-ipv6 Make all connections via IPv6
|
||||||
|
--enable-file-urls Enable file:// URLs. This is disabled by
|
||||||
|
default for security reasons.
|
||||||
|
|
||||||
## Geo-restriction:
|
## Geo-restriction:
|
||||||
--geo-verification-proxy URL Use this proxy to verify the IP address for
|
--geo-verification-proxy URL Use this proxy to verify the IP address for
|
||||||
|
|
|
@ -318,6 +318,7 @@ class YoutubeDL:
|
||||||
If not provided and the key is encrypted, yt-dlp will ask interactively
|
If not provided and the key is encrypted, yt-dlp will ask interactively
|
||||||
prefer_insecure: Use HTTP instead of HTTPS to retrieve information.
|
prefer_insecure: Use HTTP instead of HTTPS to retrieve information.
|
||||||
(Only supported by some extractors)
|
(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
|
http_headers: A dictionary of custom headers to be used for all requests
|
||||||
proxy: URL of the proxy server to use
|
proxy: URL of the proxy server to use
|
||||||
geo_verification_proxy: URL of the proxy to use for IP address verification
|
geo_verification_proxy: URL of the proxy to use for IP address verification
|
||||||
|
@ -3875,8 +3876,11 @@ def _setup_opener(self):
|
||||||
# https://github.com/ytdl-org/youtube-dl/issues/8227)
|
# https://github.com/ytdl-org/youtube-dl/issues/8227)
|
||||||
file_handler = urllib.request.FileHandler()
|
file_handler = urllib.request.FileHandler()
|
||||||
|
|
||||||
|
if not self.params.get('enable_file_urls'):
|
||||||
def file_open(*args, **kwargs):
|
def file_open(*args, **kwargs):
|
||||||
raise urllib.error.URLError('file:// scheme is explicitly disabled in yt-dlp for security reasons')
|
raise urllib.error.URLError(
|
||||||
|
'file:// URLs are explicitly disabled in yt-dlp for security reasons. '
|
||||||
|
'Use --enable-file-urls to enable at your own risk.')
|
||||||
file_handler.file_open = file_open
|
file_handler.file_open = file_open
|
||||||
|
|
||||||
opener = urllib.request.build_opener(
|
opener = urllib.request.build_opener(
|
||||||
|
|
|
@ -855,6 +855,7 @@ def parse_options(argv=None):
|
||||||
'legacyserverconnect': opts.legacy_server_connect,
|
'legacyserverconnect': opts.legacy_server_connect,
|
||||||
'nocheckcertificate': opts.no_check_certificate,
|
'nocheckcertificate': opts.no_check_certificate,
|
||||||
'prefer_insecure': opts.prefer_insecure,
|
'prefer_insecure': opts.prefer_insecure,
|
||||||
|
'enable_file_urls': opts.enable_file_urls,
|
||||||
'http_headers': opts.headers,
|
'http_headers': opts.headers,
|
||||||
'proxy': opts.proxy,
|
'proxy': opts.proxy,
|
||||||
'socket_timeout': opts.socket_timeout,
|
'socket_timeout': opts.socket_timeout,
|
||||||
|
|
|
@ -516,6 +516,11 @@ def _alias_callback(option, opt_str, value, parser, opts, nargs):
|
||||||
action='store_const', const='::', dest='source_address',
|
action='store_const', const='::', dest='source_address',
|
||||||
help='Make all connections via IPv6',
|
help='Make all connections via IPv6',
|
||||||
)
|
)
|
||||||
|
network.add_option(
|
||||||
|
'--enable-file-urls', action='store_true',
|
||||||
|
dest='enable_file_urls', default=False,
|
||||||
|
help='Enable file:// URLs. This is disabled by default for security reasons.'
|
||||||
|
)
|
||||||
|
|
||||||
geo = optparse.OptionGroup(parser, 'Geo-restriction')
|
geo = optparse.OptionGroup(parser, 'Geo-restriction')
|
||||||
geo.add_option(
|
geo.add_option(
|
||||||
|
|
Loading…
Reference in a new issue