aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/pluralsight.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2015-11-23 03:08:38 +0600
committerSergey M․ <dstftw@gmail.com>2015-11-23 03:08:38 +0600
commit02f0da20b00fa0efee6abcd1842c183b3a4cc36c (patch)
tree2ee31b560991721562f6fcf498a0b3fba49c7d79 /youtube_dl/extractor/pluralsight.py
parent4a7d108ab3c8b5ac82b8740179dae6a454218a38 (diff)
[pluralsight] Add support for alternative webpage layout (Closes #7607)
Diffstat (limited to 'youtube_dl/extractor/pluralsight.py')
-rw-r--r--youtube_dl/extractor/pluralsight.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/youtube_dl/extractor/pluralsight.py b/youtube_dl/extractor/pluralsight.py
index a11cebaf1..792316db8 100644
--- a/youtube_dl/extractor/pluralsight.py
+++ b/youtube_dl/extractor/pluralsight.py
@@ -104,20 +104,30 @@ class PluralsightIE(PluralsightBaseIE):
webpage = self._download_webpage(url, display_id)
- collection = self._parse_json(
- self._search_regex(
- r'moduleCollection\s*:\s*new\s+ModuleCollection\((\[.+?\])\s*,\s*\$rootScope\)',
- webpage, 'modules'),
- display_id)
+ modules = self._search_regex(
+ r'moduleCollection\s*:\s*new\s+ModuleCollection\((\[.+?\])\s*,\s*\$rootScope\)',
+ webpage, 'modules', default=None)
+
+ 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
for module_ in collection:
- if module_.get('moduleName') == name:
+ if name in (module_.get('moduleName'), module_.get('name')):
module = module_
for clip_ in module_.get('clips', []):
clip_index = clip_.get('clipIndex')
if clip_index is None:
+ clip_index = clip_.get('index')
+ if clip_index is None:
continue
if compat_str(clip_index) == clip_id:
clip = clip_