Option to only download XXXp or a format blacklist #406

Closed
incognico opened this Issue Aug 25, 2012 · 2 comments

Projects

None yet

3 participants

@incognico

I want the possibility to do something like "--max-quality 720p". Since the format codes are a bit random it is hard to only download a specific resolution without using -F and -f which basically does not work youtube-dl is automated.

Generally specifying --max-quality 46 for 1080p would not work since it would download 3072p being format 38 which is lower.

Alternatively --format-blacklist="37,38,46" would work for 720p but personally I prefer the first suggestion.

@canavan
canavan commented Sep 23, 2012

I've written a patch that abuses the format_limit: switch for just this. In addition to the usual functionality, when you specify a comma separated list of formats, that list works as a blacklist.

--- youtube-dl-2011.12.18       Sat Dec 17 14:06:35 CET 2011
+++ youtube-dl  Sat Dec 17 14:10:02 CET 2011
@@ -444,7 +444,7 @@
        forcefilename:    Force printing final filename.
        simulate:         Do not download the video files.
        format:           Video format code.
-       format_limit:     Highest quality format to try.
+       format_limit:     Highest quality format to try or list of formats not to try
        outtmpl:          Template for output names.
        ignoreerrors:     Do not stop on download errors.
        ratelimit:        Download speed limit, in bytes/sec.
@@ -1371,8 +1371,19 @@

                        format_limit = self._downloader.params.get('format_limit', None)
                        available_formats = self._available_formats_prefer_free if self._downloader.params.get('prefer_free_formats', False) else self._available_formats
-                       if format_limit is not None and format_limit in available_formats:
-                               format_list = available_formats[available_formats.index(format_limit):]
+
+                       if format_limit is not None:
+                               if format_limit in self._available_formats:
+                                       format_list = self._available_formats[self._available_formats.index(format_limit):]
+                               else:
+                                       format_list = self._available_formats
+                                       # print >>sys.stderr, format_limit
+                                       for limit in format_limit.split(','):
+                                               # print >>sys.stderr,  '  ',limit, ' '
+                                               # print >>sys.stderr,  '  ',self._available_formats, ' '
+                                               if limit in self._available_formats:
+                                                       # print >>sys.stderr, format_list.index(limit)
+                                                       del format_list[format_list.index(limit)]
                        else:
                                format_list = available_formats
                        existing_formats = [x for x in format_list if x in url_map]
@@ -4202,7 +4213,7 @@
        video_format.add_option('--prefer-free-formats',
                        action='store_true', dest='prefer_free_formats', default=False, help='prefer free video formats unless a specific one is requested')
        video_format.add_option('--max-quality',
-                       action='store', dest='format_limit', metavar='FORMAT', help='highest quality format to download')
+                       action='store', dest='format_limit', metavar='FORMAT', help='highest quality format to download or list of formats not to try')
        video_format.add_option('-F', '--list-formats',
                        action='store_true', dest='listformats', help='list all available formats (currently youtube only)')
@jaimeMF
Collaborator
jaimeMF commented Jan 26, 2015

With the last version of youtube-dl, you can apply filters in the format option. In your case -f 'best[width<=720]' should work. Thanks for the report!

@jaimeMF jaimeMF closed this Jan 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment