|
|
@ -41,6 +41,7 @@ from .utils import (
|
|
|
|
SameFileError,
|
|
|
|
SameFileError,
|
|
|
|
setproctitle,
|
|
|
|
setproctitle,
|
|
|
|
std_headers,
|
|
|
|
std_headers,
|
|
|
|
|
|
|
|
traverse_obj,
|
|
|
|
write_string,
|
|
|
|
write_string,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
from .update import run_update
|
|
|
|
from .update import run_update
|
|
|
@ -75,20 +76,15 @@ def _real_main(argv=None):
|
|
|
|
parser, opts, args = parseOpts(argv)
|
|
|
|
parser, opts, args = parseOpts(argv)
|
|
|
|
warnings, deprecation_warnings = [], []
|
|
|
|
warnings, deprecation_warnings = [], []
|
|
|
|
|
|
|
|
|
|
|
|
# Set user agent
|
|
|
|
|
|
|
|
if opts.user_agent is not None:
|
|
|
|
if opts.user_agent is not None:
|
|
|
|
std_headers['User-Agent'] = opts.user_agent
|
|
|
|
opts.headers.setdefault('User-Agent', opts.user_agent)
|
|
|
|
|
|
|
|
|
|
|
|
# Set referer
|
|
|
|
|
|
|
|
if opts.referer is not None:
|
|
|
|
if opts.referer is not None:
|
|
|
|
std_headers['Referer'] = opts.referer
|
|
|
|
opts.headers.setdefault('Referer', opts.referer)
|
|
|
|
|
|
|
|
|
|
|
|
# Custom HTTP headers
|
|
|
|
|
|
|
|
std_headers.update(opts.headers)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Dump user agent
|
|
|
|
# Dump user agent
|
|
|
|
if opts.dump_user_agent:
|
|
|
|
if opts.dump_user_agent:
|
|
|
|
write_string(std_headers['User-Agent'] + '\n', out=sys.stdout)
|
|
|
|
ua = traverse_obj(opts.headers, 'User-Agent', casesense=False, default=std_headers['User-Agent'])
|
|
|
|
|
|
|
|
write_string(f'{ua}\n', out=sys.stdout)
|
|
|
|
sys.exit(0)
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|
|
|
|
# Batch file verification
|
|
|
|
# Batch file verification
|
|
|
@ -767,6 +763,7 @@ def _real_main(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,
|
|
|
|
|
|
|
|
'http_headers': opts.headers,
|
|
|
|
'proxy': opts.proxy,
|
|
|
|
'proxy': opts.proxy,
|
|
|
|
'socket_timeout': opts.socket_timeout,
|
|
|
|
'socket_timeout': opts.socket_timeout,
|
|
|
|
'bidi_workaround': opts.bidi_workaround,
|
|
|
|
'bidi_workaround': opts.bidi_workaround,
|
|
|
|