diff options
author | Ricardo Garcia <[email protected]> | 2010-07-13 18:20:02 +0200 |
---|---|---|
committer | Ricardo Garcia <[email protected]> | 2010-10-31 11:28:17 +0100 |
commit | f2413e67939cb833424f2036cba627bdb164abfb (patch) | |
tree | a0593216a453c2e9b1c9123ac1afd0acaf933062 | |
parent | c833bb97dc48319f51d95cdb6bf4d78c35c35fdf (diff) | |
download | youtube-dl-f2413e67939cb833424f2036cba627bdb164abfb.tar.gz youtube-dl-f2413e67939cb833424f2036cba627bdb164abfb.zip |
Add a --max-quality flag to limit the highest quality (fixes issue #145)
-rwxr-xr-x | youtube-dl | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/youtube-dl b/youtube-dl index ba8a25a06..08297e2e0 100755 --- a/youtube-dl +++ b/youtube-dl @@ -189,6 +189,7 @@ class FileDownloader(object): forcetitle: Force printing title. simulate: Do not download the video files. format: Video format code. + format_limit: Highest quality format to try. outtmpl: Template for output names. ignoreerrors: Do not stop on download errors. ratelimit: Download speed limit, in bytes/sec. @@ -819,6 +820,13 @@ class YoutubeIE(InfoExtractor): params = self._downloader.params format_param = params.get('format', None) if format_param == '0': + format_limit = params.get('format_limit', None) + if format_limit is not None: + try: + # Start at a different format if the user has limited the maximum quality + quality_index = self._available_formats.index(format_limit) + except ValueError: + pass format_param = self._available_formats[quality_index] best_quality = True elif format_param == '-1': @@ -2111,6 +2119,8 @@ if __name__ == '__main__': action='store_const', dest='format', help='alias for -f 22', const='22') video_format.add_option('--all-formats', action='store_const', dest='format', help='download all available video formats', const='-1') + video_format.add_option('--max-quality', + action='store', dest='format_limit', metavar='FORMAT', help='highest quality format limit for -b') parser.add_option_group(video_format) verbosity = optparse.OptionGroup(parser, 'Verbosity / Simulation Options') @@ -2210,6 +2220,7 @@ if __name__ == '__main__': 'forcedescription': opts.getdescription, 'simulate': (opts.simulate or opts.geturl or opts.gettitle or opts.getthumbnail or opts.getdescription), 'format': opts.format, + 'format_limit': opts.format_limit, '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') |