mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-23 09:17:48 +00:00
[bbc] Add support for videos in news articles embedded with data-playable
This commit is contained in:
parent
6a959f2e52
commit
dab062fb6e
1 changed files with 17 additions and 0 deletions
|
@ -11,6 +11,7 @@ from ..utils import (
|
||||||
int_or_none,
|
int_or_none,
|
||||||
parse_duration,
|
parse_duration,
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
|
unescapeHTML,
|
||||||
)
|
)
|
||||||
from ..compat import compat_HTTPError
|
from ..compat import compat_HTTPError
|
||||||
|
|
||||||
|
@ -682,6 +683,21 @@ class BBCIE(BBCCoUkIE):
|
||||||
[r'data-video-player-vpid="([\da-z]{8})"',
|
[r'data-video-player-vpid="([\da-z]{8})"',
|
||||||
r'<param[^>]+name="externalIdentifier"[^>]+value="([\da-z]{8})"'],
|
r'<param[^>]+name="externalIdentifier"[^>]+value="([\da-z]{8})"'],
|
||||||
webpage, 'vpid', default=None)
|
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:
|
if programme_id:
|
||||||
formats, subtitles = self._download_media_selector(programme_id)
|
formats, subtitles = self._download_media_selector(programme_id)
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
@ -699,6 +715,7 @@ class BBCIE(BBCCoUkIE):
|
||||||
'title': title,
|
'title': title,
|
||||||
'description': description,
|
'description': description,
|
||||||
'timestamp': timestamp,
|
'timestamp': timestamp,
|
||||||
|
'duration': duration,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'subtitles': subtitles,
|
'subtitles': subtitles,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue