1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-02-19 09:52:56 +08:00

completed conversion to docopt for the downloader options

This commit is contained in:
SavinaRoja 2013-10-06 09:37:41 -04:00
parent 6211b1a635
commit b3a5c4a3cd

View File

@ -23,7 +23,7 @@ Usage:
[--verbose] [--dump-intermediate-pages] [--format FORMAT] [--verbose] [--dump-intermediate-pages] [--format FORMAT]
[--all-formats] [--prefer-free-formats] [--max-quality FORMAT] [--all-formats] [--prefer-free-formats] [--max-quality FORMAT]
[--list-formats] [--write-sub] [--write-auto-sub] [--all-subs] [--list-formats] [--write-sub] [--write-auto-sub] [--all-subs]
[--list-subs] [--sub-format FORMAT] [--sub-lang LANGS ...] [--list-subs] [--sub-format FORMAT] [--sub-langs LANGS ...]
[--username USERNAME --password PASSWORD | --netrc] [--username USERNAME --password PASSWORD | --netrc]
[--video-password PASSWORD] [--extract-audio] [--video-password PASSWORD] [--extract-audio]
[--audio-format FORMAT] [--audio-quality QUALITY] [--audio-format FORMAT] [--audio-quality QUALITY]
@ -77,7 +77,7 @@ Options:
-r, --rate-limit LIMIT maximum download rate (e.g. 50k or 44.6m) -r, --rate-limit LIMIT maximum download rate (e.g. 50k or 44.6m)
-R, --retries RETRIES number of retries [default: 10] -R, --retries RETRIES number of retries [default: 10]
--buffer-size SIZE size of download buffer (e.g. 1024 or 16k) --buffer-size SIZE size of download buffer (e.g. 1024 or 16k)
(default is 1024) [default: 1024]
--no-resize-buffer do not automatically adjust the buffer size. By --no-resize-buffer do not automatically adjust the buffer size. By
default, the buffer size is automatically resized default, the buffer size is automatically resized
from an initial value of SIZE. from an initial value of SIZE.
@ -157,7 +157,7 @@ Options:
--list-subs lists all available subtitles for the video --list-subs lists all available subtitles for the video
--sub-format FORMAT subtitle format ([sbv/vtt] youtube only) --sub-format FORMAT subtitle format ([sbv/vtt] youtube only)
[default: srt] [default: srt]
--sub-lang LANGS ... languages of the subtitles to download (optional, --sub-langs LANGS ... languages of the subtitles to download (optional,
multiple arguments) use IETF language tags like multiple arguments) use IETF language tags like
'en,pt' 'en,pt'
@ -411,14 +411,14 @@ def parseOpts(overrideArguments=None):
#downloader.add_option('-r', '--rate-limit', #downloader.add_option('-r', '--rate-limit',
# dest='ratelimit', metavar='LIMIT', help='maximum download rate (e.g. 50k or 44.6m)') # dest='ratelimit', metavar='LIMIT', help='maximum download rate (e.g. 50k or 44.6m)')
downloader.add_option('-R', '--retries', #downloader.add_option('-R', '--retries',
dest='retries', metavar='RETRIES', help='number of retries (default is %default)', default=10) # dest='retries', metavar='RETRIES', help='number of retries (default is %default)', default=10)
downloader.add_option('--buffer-size', #downloader.add_option('--buffer-size',
dest='buffersize', metavar='SIZE', help='size of download buffer (e.g. 1024 or 16k) (default is %default)', default="1024") # dest='buffersize', metavar='SIZE', help='size of download buffer (e.g. 1024 or 16k) (default is %default)', default="1024")
downloader.add_option('--no-resize-buffer', #downloader.add_option('--no-resize-buffer',
action='store_true', dest='noresizebuffer', # action='store_true', dest='noresizebuffer',
help='do not automatically adjust the buffer size. By default, the buffer size is automatically resized from an initial value of SIZE.', default=False) # help='do not automatically adjust the buffer size. By default, the buffer size is automatically resized from an initial value of SIZE.', default=False)
downloader.add_option('--test', action='store_true', dest='test', default=False, help=optparse.SUPPRESS_HELP) #downloader.add_option('--test', action='store_true', dest='test', default=False, help=optparse.SUPPRESS_HELP)
#verbosity.add_option('-q', '--quiet', #verbosity.add_option('-q', '--quiet',
# action='store_true', dest='quiet', help='activates quiet mode', default=False) # action='store_true', dest='quiet', help='activates quiet mode', default=False)
@ -691,16 +691,16 @@ def _real_main(argv=None):
if numeric_limit is None: if numeric_limit is None:
parser.error(u'invalid max_filesize specified') parser.error(u'invalid max_filesize specified')
opts['--max-filesize'] = numeric_limit opts['--max-filesize'] = numeric_limit
if opts.retries is not None: if opts['--retries'] is not None: # This should always be true, it has a default
try: try:
opts.retries = int(opts.retries) opts['--retries'] = int(opts['--retries'])
except (TypeError, ValueError) as err: except (TypeError, ValueError) as err:
parser.error(u'invalid retry count specified') parser.error(u'invalid retry count specified')
if opts.buffersize is not None: if opts['--buffer-size'] is not None: # This should always be true, it has a default
numeric_buffersize = FileDownloader.parse_bytes(opts.buffersize) numeric_buffersize = FileDownloader.parse_bytes(opts['--buffer-size'])
if numeric_buffersize is None: if numeric_buffersize is None:
parser.error(u'invalid buffer size specified') parser.error(u'invalid buffer size specified')
opts.buffersize = numeric_buffersize opts['--buffer-size'] = numeric_buffersize
try: try:
opts['--playlist-start'] = int(opts['--playlist-start']) opts['--playlist-start'] = int(opts['--playlist-start'])
if opts['--playlist-start'] <= 0: if opts['--playlist-start'] <= 0:
@ -766,9 +766,9 @@ def _real_main(argv=None):
'ignoreerrors': opts['--ignore-errors'], 'ignoreerrors': opts['--ignore-errors'],
'ratelimit': opts['--rate-limit'], 'ratelimit': opts['--rate-limit'],
'nooverwrites': opts.nooverwrites, 'nooverwrites': opts.nooverwrites,
'retries': opts.retries, 'retries': opts['--retries'],
'buffersize': opts.buffersize, 'buffersize': opts['--buffer-size'],
'noresizebuffer': opts.noresizebuffer, 'noresizebuffer': opts['--no-resize-buffer'],
'continuedl': opts.continue_dl, 'continuedl': opts.continue_dl,
'noprogress': opts['--no-progress'], 'noprogress': opts['--no-progress'],
'progress_with_newline': opts['--newline'], 'progress_with_newline': opts['--newline'],
@ -786,14 +786,14 @@ def _real_main(argv=None):
'allsubtitles': opts['--all-subs'], 'allsubtitles': opts['--all-subs'],
'listsubtitles': opts['--list-subs'], 'listsubtitles': opts['--list-subs'],
'subtitlesformat': opts['--sub-format'], 'subtitlesformat': opts['--sub-format'],
'subtitleslangs': opts['--sub-lang'], 'subtitleslangs': opts['--sub-langs'],
'matchtitle': decodeOption(opts['--match-title']), 'matchtitle': decodeOption(opts['--match-title']),
'rejecttitle': decodeOption(opts['--reject-title']), 'rejecttitle': decodeOption(opts['--reject-title']),
'max_downloads': opts['--max-downloads'], 'max_downloads': opts['--max-downloads'],
'prefer_free_formats': opts['--prefer-free-formats'], 'prefer_free_formats': opts['--prefer-free-formats'],
'verbose': opts['--verbose'], 'verbose': opts['--verbose'],
'dump_intermediate_pages': opts['--dump-intermediate-pages'], 'dump_intermediate_pages': opts['--dump-intermediate-pages'],
'test': opts.test, 'test': opts['--test'],
'keepvideo': opts.keepvideo, 'keepvideo': opts.keepvideo,
'min_filesize': opts['--min-filesize'], 'min_filesize': opts['--min-filesize'],
'max_filesize': opts['--max-filesize'], 'max_filesize': opts['--max-filesize'],