about summary refs log tree commit diff
path: root/youtube_dl/extractor/pbs.py
diff options
context:
space:
mode:
authorRemita Amine <remitamine@gmail.com>2018-05-16 18:34:25 +0100
committerRemita Amine <remitamine@gmail.com>2018-05-16 18:34:25 +0100
commiteea2fafcf506336e37ca514f72757acf8ee004af (patch)
tree013faa360e410b32c21d6f199d6c2625b635a544 /youtube_dl/extractor/pbs.py
parent6843ac5b1395157608324be71dc84803b3495857 (diff)
downloadyoutube-dl-eea2fafcf506336e37ca514f72757acf8ee004af.tar.gz
youtube-dl-eea2fafcf506336e37ca514f72757acf8ee004af.tar.xz
youtube-dl-eea2fafcf506336e37ca514f72757acf8ee004af.zip
[pbs] fix embed data extraction(fixes #16474)
Diffstat (limited to 'youtube_dl/extractor/pbs.py')
-rw-r--r--youtube_dl/extractor/pbs.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/youtube_dl/extractor/pbs.py b/youtube_dl/extractor/pbs.py
index f11d5da52..a28ee17ca 100644
--- a/youtube_dl/extractor/pbs.py
+++ b/youtube_dl/extractor/pbs.py
@@ -505,7 +505,7 @@ class PBSIE(InfoExtractor):
             if player:
                 video_info = self._parse_json(
                     self._search_regex(
-                        r'(?s)PBS\.videoData\s*=\s*({.+?});\n',
+                        [r'(?s)PBS\.videoData\s*=\s*({.+?});\n', r'window\.videoBridge\s*=\s*({.+?});'],
                         player, '%s video data' % page, default='{}'),
                     display_id, transform_source=js_to_json, fatal=False)
                 if video_info:
@@ -513,10 +513,14 @@ class PBSIE(InfoExtractor):
                     if not info:
                         info = video_info
                 if not chapters:
-                    for chapter_data in re.findall(r'(?s)chapters\.push\(({.*?})\)', player):
-                        chapter = self._parse_json(chapter_data, video_id, js_to_json, fatal=False)
-                        if not chapter:
-                            continue
+                    raw_chapters = video_info.get('chapters') or []
+                    if not raw_chapters:
+                        for chapter_data in re.findall(r'(?s)chapters\.push\(({.*?})\)', player):
+                            chapter = self._parse_json(chapter_data, video_id, js_to_json, fatal=False)
+                            if not chapter:
+                                continue
+                            raw_chapters.append(chapter)
+                    for chapter in raw_chapters:
                         start_time = float_or_none(chapter.get('start_time'), 1000)
                         duration = float_or_none(chapter.get('duration'), 1000)
                         if start_time is None or duration is None: