diff options
author | Sergey M․ <dstftw@gmail.com> | 2015-11-22 00:42:58 +0600 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2015-11-22 00:42:58 +0600 |
commit | 4c57b4853d8c1b41d729314e316cc1b83129ea18 (patch) | |
tree | 031461f55a98bddf85163dc85dd39a184e2ab21f /youtube_dl/extractor | |
parent | 38eb2968abce9078f28904046b8e26b0d87ada61 (diff) |
[pluralsight] Until listing formats request only single format
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r-- | youtube_dl/extractor/pluralsight.py | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/youtube_dl/extractor/pluralsight.py b/youtube_dl/extractor/pluralsight.py index 8481a10b0..16de0fd1c 100644 --- a/youtube_dl/extractor/pluralsight.py +++ b/youtube_dl/extractor/pluralsight.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals import json import random +import collections from .common import InfoExtractor from ..compat import ( @@ -131,13 +132,30 @@ class PluralsightIE(PluralsightBaseIE): 'high': {'width': 1024, 'height': 768}, } + AllowedQuality = collections.namedtuple('AllowedQuality', ['ext', 'qualities']) + ALLOWED_QUALITIES = ( - ('webm', ('high',)), - ('mp4', ('low', 'medium', 'high',)), + AllowedQuality('webm', ('high',)), + AllowedQuality('mp4', ('low', 'medium', 'high',)), ) + if self._downloader.params.get('listformats', False): + allowed_qualities = ALLOWED_QUALITIES + else: + def guess_allowed_qualities(): + req_format = self._downloader.params.get('format') or 'best' + req_format_split = req_format.split('-') + if len(req_format_split) > 1: + req_ext, req_quality = req_format_split + for allowed_quality in ALLOWED_QUALITIES: + if req_ext == allowed_quality.ext and req_quality in allowed_quality.qualities: + return (AllowedQuality(req_ext, (req_quality, )), ) + req_ext = 'webm' if self._downloader.params.get('prefer_free_formats') else 'mp4' + return (AllowedQuality(req_ext, ('high', )), ) + allowed_qualities = guess_allowed_qualities() + formats = [] - for ext, qualities in ALLOWED_QUALITIES: + for ext, qualities in allowed_qualities: for quality in qualities: f = QUALITIES[quality].copy() clip_post = { |