From: Philipp Hagemeister Date: Tue, 4 Mar 2014 02:49:33 +0000 (+0100) Subject: Document width, height, and resolution (#1445) X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=17b75c0de157b5a5042f0f19ba113827d811f0b7;p=youtube-dl Document width, height, and resolution (#1445) --- diff --git a/README.md b/README.md index 49b62f13f..9ac960d69 100644 --- a/README.md +++ b/README.md @@ -124,10 +124,13 @@ which means you can modify it, redistribute it or use it however you like. video id, %(playlist)s for the playlist the video is in, %(playlist_index)s for the position in the playlist and %% for a - literal percent. Use - to output to stdout. - Can also be used to download to a different - directory, for example with -o '/my/downloa - ds/%(uploader)s/%(title)s-%(id)s.%(ext)s' . + literal percent. %(height)s and %(width)s + for the width and height of the video in + the picked format. Use - to output to + stdout. Can also be used to download to a + different directory, for example with -o '/ + my/downloads/%(uploader)s/%(title)s-%(id)s. + %(ext)s' . --autonumber-size NUMBER Specifies the number of digits in %(autonumber)s when it is present in output filename template or --auto-number option diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index bbfdfb444..62ccad20c 100644 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -409,6 +409,13 @@ class YoutubeDL(object): template_dict['autonumber'] = autonumber_templ % self._num_downloads if template_dict.get('playlist_index') is not None: template_dict['playlist_index'] = '%05d' % template_dict['playlist_index'] + if template_dict.get('resolution') is None: + if template_dict.get('width') and template_dict.get('height'): + template_dict['resolution'] = '%dx%d' % (template_dict['width'], template_dict['height']) + elif template_dict.get('height'): + res = '%sp' % template_dict['height'] + elif template_dict.get('width'): + res = '?x%d' % template_dict['width'] sanitize = lambda k, v: sanitize_filename( compat_str(v), diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 72311f283..d39eb830f 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -430,6 +430,8 @@ def parseOpts(overrideArguments=None): '%(extractor)s for the provider (youtube, metacafe, etc), ' '%(id)s for the video id, %(playlist)s for the playlist the video is in, ' '%(playlist_index)s for the position in the playlist and %% for a literal percent. ' + '%(height)s and %(width)s for the width and height of the video format. ' + '%(resolution)s for a textual description of the resolution of the video format. ' 'Use - to output to stdout. Can also be used to download to a different directory, ' 'for example with -o \'/my/downloads/%(uploader)s/%(title)s-%(id)s.%(ext)s\' .')) filesystem.add_option('--autonumber-size',