aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/bbc.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2015-10-10 20:34:06 +0600
committerSergey M․ <dstftw@gmail.com>2015-10-10 21:37:23 +0600
commitdab062fb6ecd48e0c243a6d030d89b44cd44bd84 (patch)
tree4dda29532b6319f0a4f1b05a4615909e1229a8c0 /youtube_dl/extractor/bbc.py
parent6a959f2e5266dcc6037a33589eb34fad9190c63e (diff)
[bbc] Add support for videos in news articles embedded with data-playable
Diffstat (limited to 'youtube_dl/extractor/bbc.py')
-rw-r--r--youtube_dl/extractor/bbc.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/youtube_dl/extractor/bbc.py b/youtube_dl/extractor/bbc.py
index cc2f6fed2..b2b39ff21 100644
--- a/youtube_dl/extractor/bbc.py
+++ b/youtube_dl/extractor/bbc.py
@@ -11,6 +11,7 @@ from ..utils import (
int_or_none,
parse_duration,
parse_iso8601,
+ unescapeHTML,
)
from ..compat import compat_HTTPError
@@ -682,6 +683,21 @@ class BBCIE(BBCCoUkIE):
[r'data-video-player-vpid="([\da-z]{8})"',
r'<param[^>]+name="externalIdentifier"[^>]+value="([\da-z]{8})"'],
webpage, 'vpid', default=None)
+
+ duration = None
+ if not programme_id:
+ # single video in news article embedded with data-playable (e.g.
+ # http://www.bbc.com/news/world-us-canada-34473351)
+ data_playable = self._parse_json(
+ unescapeHTML(self._search_regex(
+ r'data-playable="({.+?})"', webpage, 'data playable', default='{}')),
+ programme_id, fatal=False)
+ if data_playable:
+ items = data_playable.get('settings', {}).get('playlistObject', {}).get('items')
+ if items and isinstance(items, list):
+ duration = int_or_none(items[0].get('duration'))
+ programme_id = items[0].get('vpid')
+
if programme_id:
formats, subtitles = self._download_media_selector(programme_id)
self._sort_formats(formats)
@@ -699,6 +715,7 @@ class BBCIE(BBCCoUkIE):
'title': title,
'description': description,
'timestamp': timestamp,
+ 'duration': duration,
'formats': formats,
'subtitles': subtitles,
}