diff options
author | Sergey M․ <dstftw@gmail.com> | 2016-10-21 04:35:32 +0700 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2016-10-21 04:35:32 +0700 |
commit | f8ae2c7f307e4f1bd5f3057e5c15a2a154eeea05 (patch) | |
tree | 84f43724df686c69ce8766db7ad78f52920f57c5 /youtube_dl | |
parent | 9ce0077485b9484be0aec122f6d3d1e8b4858293 (diff) |
[pluralsight] Process all clip URLs (closes #10984)
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/extractor/pluralsight.py | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/youtube_dl/extractor/pluralsight.py b/youtube_dl/extractor/pluralsight.py index 039e6eeb0..2683c0a72 100644 --- a/youtube_dl/extractor/pluralsight.py +++ b/youtube_dl/extractor/pluralsight.py @@ -4,7 +4,6 @@ import collections import json import os import random -import re from .common import InfoExtractor from ..compat import ( @@ -242,9 +241,9 @@ class PluralsightIE(PluralsightBaseIE): 'quality': '%dx%d' % (f['width'], f['height']), } format_id = '%s-%s' % (ext, quality) - clip_url = self._download_webpage( + viewclip = self._download_json( '%s/video/clips/viewclip' % self._API_BASE, display_id, - 'Downloading %s URL' % format_id, fatal=False, + 'Downloading %s viewclip JSON' % format_id, fatal=False, data=json.dumps(clip_post).encode('utf-8'), headers={'Content-Type': 'application/json;charset=utf-8'}) @@ -258,15 +257,28 @@ class PluralsightIE(PluralsightBaseIE): random.randint(2, 5), display_id, '%(video_id)s: Waiting for %(timeout)s seconds to avoid throttling') - if not clip_url: + if not viewclip: continue - f.update({ - 'url': clip_url, - 'ext': ext, - 'format_id': format_id, - 'quality': quality_key(quality), - }) - formats.append(f) + + clip_urls = viewclip.get('urls') + if not isinstance(clip_urls, list): + continue + + for clip_url_data in clip_urls: + clip_url = clip_url_data.get('url') + if not clip_url: + continue + cdn = clip_url_data.get('cdn') + clip_f = f.copy() + clip_f.update({ + 'url': clip_url, + 'ext': ext, + 'format_id': '%s-%s' % (format_id, cdn) if cdn else format_id, + 'quality': quality_key(quality), + 'source_preference': int_or_none(clip_url_data.get('rank')), + }) + formats.append(clip_f) + self._sort_formats(formats) duration = int_or_none( |