-from __future__ import unicode_literals
-
import collections
import json
import os
float_or_none,
int_or_none,
parse_duration,
+ parse_qs,
qualities,
srt_subtitles_timecode,
try_get,
}
}'''
- def _real_initialize(self):
- self._login()
-
- def _login(self):
- username, password = self._get_login_info()
- if username is None:
- return
-
+ def _perform_login(self, username, password):
login_page = self._download_webpage(
self._LOGIN_URL, None, 'Downloading login page')
return srt
def _real_extract(self, url):
- qs = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query)
+ qs = parse_qs(url)
author = qs.get('author', [None])[0]
name = qs.get('name', [None])[0]
# In order to minimize the number of calls to ViewClip API and reduce
# the probability of being throttled or banned by Pluralsight we will request
# only single format until formats listing was explicitly requested.
- if self._downloader.params.get('listformats', False):
+ if self.get_param('listformats', False):
allowed_qualities = ALLOWED_QUALITIES
else:
def guess_allowed_qualities():
- req_format = self._downloader.params.get('format') or 'best'
+ req_format = self.get_param('format') or 'best'
req_format_split = req_format.split('-', 1)
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'
+ req_ext = 'webm' if self.get_param('prefer_free_formats') else 'mp4'
return (AllowedQuality(req_ext, (best_quality, )), )
allowed_qualities = guess_allowed_qualities()
# To somewhat reduce the probability of these consequences
# we will sleep random amount of time before each call to ViewClip.
self._sleep(
- random.randint(2, 5), display_id,
+ random.randint(5, 10), display_id,
'%(video_id)s: Waiting for %(timeout)s seconds to avoid throttling')
if not viewclip:
})
formats.append(clip_f)
- self._sort_formats(formats)
-
duration = int_or_none(
clip.get('duration')) or parse_duration(clip.get('formattedDuration'))