[pluralsight] Add support for alternative webpage layout (Closes #7607)

This commit is contained in:
Sergey M․ 2015-11-23 03:08:38 +06:00
parent 4a7d108ab3
commit 02f0da20b0

View file

@ -104,19 +104,29 @@ class PluralsightIE(PluralsightBaseIE):
webpage = self._download_webpage(url, display_id) webpage = self._download_webpage(url, display_id)
collection = self._parse_json( modules = self._search_regex(
self._search_regex( r'moduleCollection\s*:\s*new\s+ModuleCollection\((\[.+?\])\s*,\s*\$rootScope\)',
r'moduleCollection\s*:\s*new\s+ModuleCollection\((\[.+?\])\s*,\s*\$rootScope\)', webpage, 'modules', default=None)
webpage, 'modules'),
display_id) if modules:
collection = self._parse_json(modules, display_id)
else:
# Webpage may be served in different layout (see
# https://github.com/rg3/youtube-dl/issues/7607)
collection = self._parse_json(
self._search_regex(
r'var\s+initialState\s*=\s*({.+?});\n', webpage, 'initial state'),
display_id)['course']['modules']
module, clip = None, None module, clip = None, None
for module_ in collection: for module_ in collection:
if module_.get('moduleName') == name: if name in (module_.get('moduleName'), module_.get('name')):
module = module_ module = module_
for clip_ in module_.get('clips', []): for clip_ in module_.get('clips', []):
clip_index = clip_.get('clipIndex') clip_index = clip_.get('clipIndex')
if clip_index is None:
clip_index = clip_.get('index')
if clip_index is None: if clip_index is None:
continue continue
if compat_str(clip_index) == clip_id: if compat_str(clip_index) == clip_id: