@ -1330,6 +1350,9 @@ class YoutubeIE(InfoExtractor):
if len(existing_formats) == 0:
self._downloader.trouble(u'ERROR: no known formats available for video')
return
if self._downloader.params.get('listformats', None):
self._print_formats(existing_formats)
sys.exit(0)
if req_format is None or req_format == 'best':
video_url_list = [(existing_formats[0], url_map[existing_formats[0]])] # Best quality
elif req_format == 'worst':
@ -3564,6 +3587,8 @@ def parseOpts():
action='store_const', dest='format', help='download all available video formats', const='all')
video_format.add_option('--max-quality',
action='store', dest='format_limit', metavar='FORMAT', help='highest quality format to download')
video_format.add_option('-L', '--list-formats',
action='store_true', dest='listformats', help='list all available formats')
verbosity.add_option('-q', '--quiet',
@ -3784,6 +3809,7 @@ def main():
'skip_download': (opts.skip_download or opts.simulate or opts.geturl or opts.gettitle or opts.getthumbnail or opts.getdescription or opts.getfilename or opts.getformat),
'format': opts.format,
'format_limit': opts.format_limit,
'listformats': opts.listformats,
'outtmpl': ((opts.outtmpl is not None and opts.outtmpl.decode(preferredencoding()))
or (opts.format == '-1' and opts.usetitle and u'%(stitle)s-%(id)s-%(format)s.%(ext)s')
or (opts.format == '-1' and opts.useliteral and u'%(title)s-%(id)s-%(format)s.%(ext)s')