1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-02-14 14:57:49 +08:00

Converted --proxy to docopt

This commit is contained in:
SavinaRoja 2013-10-05 21:13:24 -04:00
parent 984a6b80f9
commit 3dc8c8b19f

View File

@ -349,7 +349,7 @@ def parseOpts(overrideArguments=None):
general.add_option('--extractor-descriptions', general.add_option('--extractor-descriptions',
action='store_true', dest='list_extractor_descriptions', action='store_true', dest='list_extractor_descriptions',
help='Output descriptions of all supported extractors', default=False) help='Output descriptions of all supported extractors', default=False)
general.add_option('--proxy', dest='proxy', default=None, help='Use the specified HTTP/HTTPS proxy', metavar='URL') #general.add_option('--proxy', dest='proxy', default=None, help='Use the specified HTTP/HTTPS proxy', metavar='URL')
general.add_option('--no-check-certificate', action='store_true', dest='no_check_certificate', default=False, help='Suppress HTTPS certificate validation.') general.add_option('--no-check-certificate', action='store_true', dest='no_check_certificate', default=False, help='Suppress HTTPS certificate validation.')
@ -483,8 +483,8 @@ def parseOpts(overrideArguments=None):
filesystem.add_option('--restrict-filenames', filesystem.add_option('--restrict-filenames',
action='store_true', dest='restrictfilenames', action='store_true', dest='restrictfilenames',
help='Restrict filenames to only ASCII characters, and avoid "&" and spaces in filenames', default=False) help='Restrict filenames to only ASCII characters, and avoid "&" and spaces in filenames', default=False)
filesystem.add_option('-a', '--batch-file', #filesystem.add_option('-a', '--batch-file',
dest='batchfile', metavar='FILE', help='file containing URLs to download (\'-\' for stdin)') # dest='batchfile', metavar='FILE', help='file containing URLs to download (\'-\' for stdin)')
filesystem.add_option('-w', '--no-overwrites', filesystem.add_option('-w', '--no-overwrites',
action='store_true', dest='nooverwrites', help='do not overwrite files', default=False) action='store_true', dest='nooverwrites', help='do not overwrite files', default=False)
filesystem.add_option('-c', '--continue', filesystem.add_option('-c', '--continue',
@ -595,12 +595,12 @@ def _real_main(argv=None):
# Batch file verification # Batch file verification
batchurls = [] batchurls = []
if opts.batchfile is not None: if opts['--batch-file']:
try: try:
if opts.batchfile == '-': if opts['--batch-file'] == '-':
batchfd = sys.stdin batchfd = sys.stdin
else: else:
batchfd = open(opts.batchfile, 'r') batchfd = open(opts['--batch-file'], 'r')
batchurls = batchfd.readlines() batchurls = batchfd.readlines()
batchurls = [x.strip() for x in batchurls] batchurls = [x.strip() for x in batchurls]
batchurls = [x for x in batchurls if len(x) > 0 and not re.search(r'^[#/;]', x)] batchurls = [x for x in batchurls if len(x) > 0 and not re.search(r'^[#/;]', x)]
@ -613,11 +613,11 @@ def _real_main(argv=None):
# General configuration # General configuration
cookie_processor = compat_urllib_request.HTTPCookieProcessor(jar) cookie_processor = compat_urllib_request.HTTPCookieProcessor(jar)
if opts.proxy is not None: if opts['--proxy']:
if opts.proxy == '': if opts['--proxy'] == '': # Will this ever happen?
proxies = {} proxies = {}
else: else:
proxies = {'http': opts.proxy, 'https': opts.proxy} proxies = {'http': opts['--proxy'], 'https': opts['--proxy']}
else: else:
proxies = compat_urllib_request.getproxies() proxies = compat_urllib_request.getproxies()
# Set HTTPS proxy to HTTP one if given (https://github.com/rg3/youtube-dl/issues/805) # Set HTTPS proxy to HTTP one if given (https://github.com/rg3/youtube-dl/issues/805)