1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-14 05:17:25 +00:00

Suppress help for all deprecated options and print warning when used

This commit is contained in:
Sergey M․ 2017-02-24 06:04:27 +07:00
parent f2980fddeb
commit be5df5ee31
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D
3 changed files with 20 additions and 9 deletions

View File

@ -328,11 +328,21 @@ class YoutubeDL(object):
self.params.update(params) self.params.update(params)
self.cache = Cache(self) self.cache = Cache(self)
if self.params.get('cn_verification_proxy') is not None: def check_deprecated(param, option, suggestion):
self.report_warning('--cn-verification-proxy is deprecated. Use --geo-verification-proxy instead.') if self.params.get(param) is not None:
self.report_warning(
'%s is deprecated. Use %s instead.' % (option, suggestion))
return True
return False
if check_deprecated('cn_verification_proxy', '--cn-verification-proxy', '--geo-verification-proxy'):
if self.params.get('geo_verification_proxy') is None: if self.params.get('geo_verification_proxy') is None:
self.params['geo_verification_proxy'] = self.params['cn_verification_proxy'] self.params['geo_verification_proxy'] = self.params['cn_verification_proxy']
check_deprecated('autonumber_size', '--autonumber-size', 'output template with %(autonumber)0Nd, where N in the number of digits')
check_deprecated('autonumber', '--auto-number', '-o "%(autonumber)s-%(title)s.%(ext)s"')
check_deprecated('usetitle', '--title', '-o "%(title)s-%(id)s.%(ext)s"')
if params.get('bidi_workaround', False): if params.get('bidi_workaround', False):
try: try:
import pty import pty

View File

@ -416,6 +416,9 @@ def _real_main(argv=None):
'config_location': opts.config_location, 'config_location': opts.config_location,
'geo_bypass': opts.geo_bypass, 'geo_bypass': opts.geo_bypass,
'geo_bypass_country': opts.geo_bypass_country, 'geo_bypass_country': opts.geo_bypass_country,
# just for deprecation check
'autonumber': opts.autonumber if opts.autonumber is True else None,
'usetitle': opts.usetitle if opts.usetitle is True else None,
} }
with YoutubeDL(ydl_opts) as ydl: with YoutubeDL(ydl_opts) as ydl:

View File

@ -679,10 +679,8 @@ def parseOpts(overrideArguments=None):
help=('Output filename template, see the "OUTPUT TEMPLATE" for all the info')) help=('Output filename template, see the "OUTPUT TEMPLATE" for all the info'))
filesystem.add_option( filesystem.add_option(
'--autonumber-size', '--autonumber-size',
dest='autonumber_size', metavar='NUMBER', default=5, type=int, dest='autonumber_size', metavar='NUMBER', type=int,
help='[deprecated; use output template with %(autonumber)0Nd, where N in the number of digits] ' help=optparse.SUPPRESS_HELP)
'Specify the number of digits in %(autonumber)s when it is present '
'in output filename template or --auto-number option is given (default is %default)')
filesystem.add_option( filesystem.add_option(
'--autonumber-start', '--autonumber-start',
dest='autonumber_start', metavar='NUMBER', default=1, type=int, dest='autonumber_start', metavar='NUMBER', default=1, type=int,
@ -694,15 +692,15 @@ def parseOpts(overrideArguments=None):
filesystem.add_option( filesystem.add_option(
'-A', '--auto-number', '-A', '--auto-number',
action='store_true', dest='autonumber', default=False, action='store_true', dest='autonumber', default=False,
help='[deprecated; use -o "%(autonumber)s-%(title)s.%(ext)s" ] Number downloaded files starting from 00000') help=optparse.SUPPRESS_HELP)
filesystem.add_option( filesystem.add_option(
'-t', '--title', '-t', '--title',
action='store_true', dest='usetitle', default=False, action='store_true', dest='usetitle', default=False,
help='[deprecated] Use title in file name (default)') help=optparse.SUPPRESS_HELP)
filesystem.add_option( filesystem.add_option(
'-l', '--literal', default=False, '-l', '--literal', default=False,
action='store_true', dest='usetitle', action='store_true', dest='usetitle',
help='[deprecated] Alias of --title') help=optparse.SUPPRESS_HELP)
filesystem.add_option( filesystem.add_option(
'-w', '--no-overwrites', '-w', '--no-overwrites',
action='store_true', dest='nooverwrites', default=False, action='store_true', dest='nooverwrites', default=False,