aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPhilipp Hagemeister <[email protected]>2011-12-08 21:38:28 +0100
committerPhilipp Hagemeister <[email protected]>2011-12-08 21:38:28 +0100
commit23e6b8adc8197da4cfaa831c08f3c2e627bbabdd (patch)
tree97c543668c47eb7662791806d4c781f976daccae
parent3e0ea7d07ab0eb649edae89d6fbac827f2af6478 (diff)
downloadyoutube-dl-23e6b8adc8197da4cfaa831c08f3c2e627bbabdd.tar.gz
youtube-dl-23e6b8adc8197da4cfaa831c08f3c2e627bbabdd.zip
--prefer-free-formats (Closes #231)
-rwxr-xr-xyoutube_dl/__init__.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py
index 3fed554df..306ecca51 100755
--- a/youtube_dl/__init__.py
+++ b/youtube_dl/__init__.py
@@ -1121,6 +1121,7 @@ class YoutubeIE(InfoExtractor):
_NETRC_MACHINE = 'youtube'
# Listed in order of quality
_available_formats = ['38', '37', '22', '45', '35', '44', '34', '18', '43', '6', '5', '17', '13']
+ _available_formats_prefer_free = ['38', '37', '45', '22', '44', '35', '43', '34', '18', '6', '5', '17', '13']
_video_extensions = {
'13': '3gp',
'17': 'mp4',
@@ -1370,10 +1371,11 @@ class YoutubeIE(InfoExtractor):
url_map = dict((ud['itag'][0], ud['url'][0]) for ud in url_data)
format_limit = self._downloader.params.get('format_limit', None)
- if format_limit is not None and format_limit in self._available_formats:
- format_list = self._available_formats[self._available_formats.index(format_limit):]
+ 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):]
else:
- format_list = self._available_formats
+ format_list = available_formats
existing_formats = [x for x in format_list if x in url_map]
if len(existing_formats) == 0:
self._downloader.trouble(u'ERROR: no known formats available for video')
@@ -4175,6 +4177,8 @@ def parseOpts():
action='store', dest='format', metavar='FORMAT', help='video format code')
video_format.add_option('--all-formats',
action='store_const', dest='format', help='download all available video formats', const='all')
+ 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')
video_format.add_option('-F', '--list-formats',
@@ -4439,6 +4443,7 @@ def _real_main():
'matchtitle': opts.matchtitle,
'rejecttitle': opts.rejecttitle,
'max_downloads': opts.max_downloads,
+ 'prefer_free_formats': opts.prefer_free_formats,
})
for extractor in extractors:
fd.add_info_extractor(extractor)