]> jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/bbc.py
[20min] Fix embeds extraction
[yt-dlp.git] / youtube_dl / extractor / bbc.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5 import itertools
6
7 from .common import InfoExtractor
8 from ..utils import (
9 clean_html,
10 dict_get,
11 ExtractorError,
12 float_or_none,
13 get_element_by_class,
14 int_or_none,
15 parse_duration,
16 parse_iso8601,
17 try_get,
18 unescapeHTML,
19 urlencode_postdata,
20 urljoin,
21 )
22 from ..compat import (
23 compat_etree_fromstring,
24 compat_HTTPError,
25 compat_urlparse,
26 )
27
28
29 class BBCCoUkIE(InfoExtractor):
30 IE_NAME = 'bbc.co.uk'
31 IE_DESC = 'BBC iPlayer'
32 _ID_REGEX = r'[pb][\da-z]{7}'
33 _VALID_URL = r'''(?x)
34 https?://
35 (?:www\.)?bbc\.co\.uk/
36 (?:
37 programmes/(?!articles/)|
38 iplayer(?:/[^/]+)?/(?:episode/|playlist/)|
39 music/(?:clips|audiovideo/popular)[/#]|
40 radio/player/
41 )
42 (?P<id>%s)(?!/(?:episodes|broadcasts|clips))
43 ''' % _ID_REGEX
44
45 _LOGIN_URL = 'https://account.bbc.com/signin'
46 _NETRC_MACHINE = 'bbc'
47
48 _MEDIASELECTOR_URLS = [
49 # Provides HQ HLS streams with even better quality that pc mediaset but fails
50 # with geolocation in some cases when it's even not geo restricted at all (e.g.
51 # http://www.bbc.co.uk/programmes/b06bp7lf). Also may fail with selectionunavailable.
52 'http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/iptv-all/vpid/%s',
53 'http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/pc/vpid/%s',
54 ]
55
56 _MEDIASELECTION_NS = 'http://bbc.co.uk/2008/mp/mediaselection'
57 _EMP_PLAYLIST_NS = 'http://bbc.co.uk/2008/emp/playlist'
58
59 _NAMESPACES = (
60 _MEDIASELECTION_NS,
61 _EMP_PLAYLIST_NS,
62 )
63
64 _TESTS = [
65 {
66 'url': 'http://www.bbc.co.uk/programmes/b039g8p7',
67 'info_dict': {
68 'id': 'b039d07m',
69 'ext': 'flv',
70 'title': 'Leonard Cohen, Kaleidoscope - BBC Radio 4',
71 'description': 'The Canadian poet and songwriter reflects on his musical career.',
72 },
73 'params': {
74 # rtmp download
75 'skip_download': True,
76 }
77 },
78 {
79 'url': 'http://www.bbc.co.uk/iplayer/episode/b00yng5w/The_Man_in_Black_Series_3_The_Printed_Name/',
80 'info_dict': {
81 'id': 'b00yng1d',
82 'ext': 'flv',
83 'title': 'The Man in Black: Series 3: The Printed Name',
84 'description': "Mark Gatiss introduces Nicholas Pierpan's chilling tale of a writer's devilish pact with a mysterious man. Stars Ewan Bailey.",
85 'duration': 1800,
86 },
87 'params': {
88 # rtmp download
89 'skip_download': True,
90 },
91 'skip': 'Episode is no longer available on BBC iPlayer Radio',
92 },
93 {
94 'url': 'http://www.bbc.co.uk/iplayer/episode/b03vhd1f/The_Voice_UK_Series_3_Blind_Auditions_5/',
95 'info_dict': {
96 'id': 'b00yng1d',
97 'ext': 'flv',
98 'title': 'The Voice UK: Series 3: Blind Auditions 5',
99 'description': 'Emma Willis and Marvin Humes present the fifth set of blind auditions in the singing competition, as the coaches continue to build their teams based on voice alone.',
100 'duration': 5100,
101 },
102 'params': {
103 # rtmp download
104 'skip_download': True,
105 },
106 'skip': 'Currently BBC iPlayer TV programmes are available to play in the UK only',
107 },
108 {
109 'url': 'http://www.bbc.co.uk/iplayer/episode/p026c7jt/tomorrows-worlds-the-unearthly-history-of-science-fiction-2-invasion',
110 'info_dict': {
111 'id': 'b03k3pb7',
112 'ext': 'flv',
113 'title': "Tomorrow's Worlds: The Unearthly History of Science Fiction",
114 'description': '2. Invasion',
115 'duration': 3600,
116 },
117 'params': {
118 # rtmp download
119 'skip_download': True,
120 },
121 'skip': 'Currently BBC iPlayer TV programmes are available to play in the UK only',
122 }, {
123 'url': 'http://www.bbc.co.uk/programmes/b04v20dw',
124 'info_dict': {
125 'id': 'b04v209v',
126 'ext': 'flv',
127 'title': 'Pete Tong, The Essential New Tune Special',
128 'description': "Pete has a very special mix - all of 2014's Essential New Tunes!",
129 'duration': 10800,
130 },
131 'params': {
132 # rtmp download
133 'skip_download': True,
134 },
135 'skip': 'Episode is no longer available on BBC iPlayer Radio',
136 }, {
137 'url': 'http://www.bbc.co.uk/music/clips/p022h44b',
138 'note': 'Audio',
139 'info_dict': {
140 'id': 'p022h44j',
141 'ext': 'flv',
142 'title': 'BBC Proms Music Guides, Rachmaninov: Symphonic Dances',
143 'description': "In this Proms Music Guide, Andrew McGregor looks at Rachmaninov's Symphonic Dances.",
144 'duration': 227,
145 },
146 'params': {
147 # rtmp download
148 'skip_download': True,
149 }
150 }, {
151 'url': 'http://www.bbc.co.uk/music/clips/p025c0zz',
152 'note': 'Video',
153 'info_dict': {
154 'id': 'p025c103',
155 'ext': 'flv',
156 'title': 'Reading and Leeds Festival, 2014, Rae Morris - Closer (Live on BBC Three)',
157 'description': 'Rae Morris performs Closer for BBC Three at Reading 2014',
158 'duration': 226,
159 },
160 'params': {
161 # rtmp download
162 'skip_download': True,
163 }
164 }, {
165 'url': 'http://www.bbc.co.uk/iplayer/episode/b054fn09/ad/natural-world-20152016-2-super-powered-owls',
166 'info_dict': {
167 'id': 'p02n76xf',
168 'ext': 'flv',
169 'title': 'Natural World, 2015-2016: 2. Super Powered Owls',
170 'description': 'md5:e4db5c937d0e95a7c6b5e654d429183d',
171 'duration': 3540,
172 },
173 'params': {
174 # rtmp download
175 'skip_download': True,
176 },
177 'skip': 'geolocation',
178 }, {
179 'url': 'http://www.bbc.co.uk/iplayer/episode/b05zmgwn/royal-academy-summer-exhibition',
180 'info_dict': {
181 'id': 'b05zmgw1',
182 'ext': 'flv',
183 'description': 'Kirsty Wark and Morgan Quaintance visit the Royal Academy as it prepares for its annual artistic extravaganza, meeting people who have come together to make the show unique.',
184 'title': 'Royal Academy Summer Exhibition',
185 'duration': 3540,
186 },
187 'params': {
188 # rtmp download
189 'skip_download': True,
190 },
191 'skip': 'geolocation',
192 }, {
193 # iptv-all mediaset fails with geolocation however there is no geo restriction
194 # for this programme at all
195 'url': 'http://www.bbc.co.uk/programmes/b06rkn85',
196 'info_dict': {
197 'id': 'b06rkms3',
198 'ext': 'flv',
199 'title': "Best of the Mini-Mixes 2015: Part 3, Annie Mac's Friday Night - BBC Radio 1",
200 'description': "Annie has part three in the Best of the Mini-Mixes 2015, plus the year's Most Played!",
201 },
202 'params': {
203 # rtmp download
204 'skip_download': True,
205 },
206 'skip': 'Now it\'s really geo-restricted',
207 }, {
208 # compact player (https://github.com/rg3/youtube-dl/issues/8147)
209 'url': 'http://www.bbc.co.uk/programmes/p028bfkf/player',
210 'info_dict': {
211 'id': 'p028bfkj',
212 'ext': 'flv',
213 'title': 'Extract from BBC documentary Look Stranger - Giant Leeks and Magic Brews',
214 'description': 'Extract from BBC documentary Look Stranger - Giant Leeks and Magic Brews',
215 },
216 'params': {
217 # rtmp download
218 'skip_download': True,
219 },
220 }, {
221 'url': 'http://www.bbc.co.uk/iplayer/playlist/p01dvks4',
222 'only_matching': True,
223 }, {
224 'url': 'http://www.bbc.co.uk/music/clips#p02frcc3',
225 'only_matching': True,
226 }, {
227 'url': 'http://www.bbc.co.uk/iplayer/cbeebies/episode/b0480276/bing-14-atchoo',
228 'only_matching': True,
229 }, {
230 'url': 'http://www.bbc.co.uk/radio/player/p03cchwf',
231 'only_matching': True,
232 }, {
233 'url': 'https://www.bbc.co.uk/music/audiovideo/popular#p055bc55',
234 'only_matching': True,
235 }]
236
237 _USP_RE = r'/([^/]+?)\.ism(?:\.hlsv2\.ism)?/[^/]+\.m3u8'
238
239 def _login(self):
240 username, password = self._get_login_info()
241 if username is None:
242 return
243
244 login_page = self._download_webpage(
245 self._LOGIN_URL, None, 'Downloading signin page')
246
247 login_form = self._hidden_inputs(login_page)
248
249 login_form.update({
250 'username': username,
251 'password': password,
252 })
253
254 post_url = urljoin(self._LOGIN_URL, self._search_regex(
255 r'<form[^>]+action=(["\'])(?P<url>.+?)\1', login_page,
256 'post url', default=self._LOGIN_URL, group='url'))
257
258 response, urlh = self._download_webpage_handle(
259 post_url, None, 'Logging in', data=urlencode_postdata(login_form),
260 headers={'Referer': self._LOGIN_URL})
261
262 if self._LOGIN_URL in urlh.geturl():
263 error = clean_html(get_element_by_class('form-message', response))
264 if error:
265 raise ExtractorError(
266 'Unable to login: %s' % error, expected=True)
267 raise ExtractorError('Unable to log in')
268
269 def _real_initialize(self):
270 self._login()
271
272 class MediaSelectionError(Exception):
273 def __init__(self, id):
274 self.id = id
275
276 def _extract_asx_playlist(self, connection, programme_id):
277 asx = self._download_xml(connection.get('href'), programme_id, 'Downloading ASX playlist')
278 return [ref.get('href') for ref in asx.findall('./Entry/ref')]
279
280 def _extract_items(self, playlist):
281 return playlist.findall('./{%s}item' % self._EMP_PLAYLIST_NS)
282
283 def _findall_ns(self, element, xpath):
284 elements = []
285 for ns in self._NAMESPACES:
286 elements.extend(element.findall(xpath % ns))
287 return elements
288
289 def _extract_medias(self, media_selection):
290 error = media_selection.find('./{%s}error' % self._MEDIASELECTION_NS)
291 if error is None:
292 media_selection.find('./{%s}error' % self._EMP_PLAYLIST_NS)
293 if error is not None:
294 raise BBCCoUkIE.MediaSelectionError(error.get('id'))
295 return self._findall_ns(media_selection, './{%s}media')
296
297 def _extract_connections(self, media):
298 return self._findall_ns(media, './{%s}connection')
299
300 def _get_subtitles(self, media, programme_id):
301 subtitles = {}
302 for connection in self._extract_connections(media):
303 captions = self._download_xml(connection.get('href'), programme_id, 'Downloading captions')
304 lang = captions.get('{http://www.w3.org/XML/1998/namespace}lang', 'en')
305 subtitles[lang] = [
306 {
307 'url': connection.get('href'),
308 'ext': 'ttml',
309 },
310 ]
311 return subtitles
312
313 def _raise_extractor_error(self, media_selection_error):
314 raise ExtractorError(
315 '%s returned error: %s' % (self.IE_NAME, media_selection_error.id),
316 expected=True)
317
318 def _download_media_selector(self, programme_id):
319 last_exception = None
320 for mediaselector_url in self._MEDIASELECTOR_URLS:
321 try:
322 return self._download_media_selector_url(
323 mediaselector_url % programme_id, programme_id)
324 except BBCCoUkIE.MediaSelectionError as e:
325 if e.id in ('notukerror', 'geolocation', 'selectionunavailable'):
326 last_exception = e
327 continue
328 self._raise_extractor_error(e)
329 self._raise_extractor_error(last_exception)
330
331 def _download_media_selector_url(self, url, programme_id=None):
332 try:
333 media_selection = self._download_xml(
334 url, programme_id, 'Downloading media selection XML')
335 except ExtractorError as ee:
336 if isinstance(ee.cause, compat_HTTPError) and ee.cause.code in (403, 404):
337 media_selection = compat_etree_fromstring(ee.cause.read().decode('utf-8'))
338 else:
339 raise
340 return self._process_media_selector(media_selection, programme_id)
341
342 def _process_media_selector(self, media_selection, programme_id):
343 formats = []
344 subtitles = None
345 urls = []
346
347 for media in self._extract_medias(media_selection):
348 kind = media.get('kind')
349 if kind in ('video', 'audio'):
350 bitrate = int_or_none(media.get('bitrate'))
351 encoding = media.get('encoding')
352 service = media.get('service')
353 width = int_or_none(media.get('width'))
354 height = int_or_none(media.get('height'))
355 file_size = int_or_none(media.get('media_file_size'))
356 for connection in self._extract_connections(media):
357 href = connection.get('href')
358 if href in urls:
359 continue
360 if href:
361 urls.append(href)
362 conn_kind = connection.get('kind')
363 protocol = connection.get('protocol')
364 supplier = connection.get('supplier')
365 transfer_format = connection.get('transferFormat')
366 format_id = supplier or conn_kind or protocol
367 if service:
368 format_id = '%s_%s' % (service, format_id)
369 # ASX playlist
370 if supplier == 'asx':
371 for i, ref in enumerate(self._extract_asx_playlist(connection, programme_id)):
372 formats.append({
373 'url': ref,
374 'format_id': 'ref%s_%s' % (i, format_id),
375 })
376 elif transfer_format == 'dash':
377 formats.extend(self._extract_mpd_formats(
378 href, programme_id, mpd_id=format_id, fatal=False))
379 elif transfer_format == 'hls':
380 formats.extend(self._extract_m3u8_formats(
381 href, programme_id, ext='mp4', entry_protocol='m3u8_native',
382 m3u8_id=format_id, fatal=False))
383 if re.search(self._USP_RE, href):
384 usp_formats = self._extract_m3u8_formats(
385 re.sub(self._USP_RE, r'/\1.ism/\1.m3u8', href),
386 programme_id, ext='mp4', entry_protocol='m3u8_native',
387 m3u8_id=format_id, fatal=False)
388 for f in usp_formats:
389 if f.get('height') and f['height'] > 720:
390 continue
391 formats.append(f)
392 elif transfer_format == 'hds':
393 formats.extend(self._extract_f4m_formats(
394 href, programme_id, f4m_id=format_id, fatal=False))
395 else:
396 if not service and not supplier and bitrate:
397 format_id += '-%d' % bitrate
398 fmt = {
399 'format_id': format_id,
400 'filesize': file_size,
401 }
402 if kind == 'video':
403 fmt.update({
404 'width': width,
405 'height': height,
406 'tbr': bitrate,
407 'vcodec': encoding,
408 })
409 else:
410 fmt.update({
411 'abr': bitrate,
412 'acodec': encoding,
413 'vcodec': 'none',
414 })
415 if protocol in ('http', 'https'):
416 # Direct link
417 fmt.update({
418 'url': href,
419 })
420 elif protocol == 'rtmp':
421 application = connection.get('application', 'ondemand')
422 auth_string = connection.get('authString')
423 identifier = connection.get('identifier')
424 server = connection.get('server')
425 fmt.update({
426 'url': '%s://%s/%s?%s' % (protocol, server, application, auth_string),
427 'play_path': identifier,
428 'app': '%s?%s' % (application, auth_string),
429 'page_url': 'http://www.bbc.co.uk',
430 'player_url': 'http://www.bbc.co.uk/emp/releases/iplayer/revisions/617463_618125_4/617463_618125_4_emp.swf',
431 'rtmp_live': False,
432 'ext': 'flv',
433 })
434 else:
435 continue
436 formats.append(fmt)
437 elif kind == 'captions':
438 subtitles = self.extract_subtitles(media, programme_id)
439 return formats, subtitles
440
441 def _download_playlist(self, playlist_id):
442 try:
443 playlist = self._download_json(
444 'http://www.bbc.co.uk/programmes/%s/playlist.json' % playlist_id,
445 playlist_id, 'Downloading playlist JSON')
446
447 version = playlist.get('defaultAvailableVersion')
448 if version:
449 smp_config = version['smpConfig']
450 title = smp_config['title']
451 description = smp_config['summary']
452 for item in smp_config['items']:
453 kind = item['kind']
454 if kind not in ('programme', 'radioProgramme'):
455 continue
456 programme_id = item.get('vpid')
457 duration = int_or_none(item.get('duration'))
458 formats, subtitles = self._download_media_selector(programme_id)
459 return programme_id, title, description, duration, formats, subtitles
460 except ExtractorError as ee:
461 if not (isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 404):
462 raise
463
464 # fallback to legacy playlist
465 return self._process_legacy_playlist(playlist_id)
466
467 def _process_legacy_playlist_url(self, url, display_id):
468 playlist = self._download_legacy_playlist_url(url, display_id)
469 return self._extract_from_legacy_playlist(playlist, display_id)
470
471 def _process_legacy_playlist(self, playlist_id):
472 return self._process_legacy_playlist_url(
473 'http://www.bbc.co.uk/iplayer/playlist/%s' % playlist_id, playlist_id)
474
475 def _download_legacy_playlist_url(self, url, playlist_id=None):
476 return self._download_xml(
477 url, playlist_id, 'Downloading legacy playlist XML')
478
479 def _extract_from_legacy_playlist(self, playlist, playlist_id):
480 no_items = playlist.find('./{%s}noItems' % self._EMP_PLAYLIST_NS)
481 if no_items is not None:
482 reason = no_items.get('reason')
483 if reason == 'preAvailability':
484 msg = 'Episode %s is not yet available' % playlist_id
485 elif reason == 'postAvailability':
486 msg = 'Episode %s is no longer available' % playlist_id
487 elif reason == 'noMedia':
488 msg = 'Episode %s is not currently available' % playlist_id
489 else:
490 msg = 'Episode %s is not available: %s' % (playlist_id, reason)
491 raise ExtractorError(msg, expected=True)
492
493 for item in self._extract_items(playlist):
494 kind = item.get('kind')
495 if kind not in ('programme', 'radioProgramme'):
496 continue
497 title = playlist.find('./{%s}title' % self._EMP_PLAYLIST_NS).text
498 description_el = playlist.find('./{%s}summary' % self._EMP_PLAYLIST_NS)
499 description = description_el.text if description_el is not None else None
500
501 def get_programme_id(item):
502 def get_from_attributes(item):
503 for p in('identifier', 'group'):
504 value = item.get(p)
505 if value and re.match(r'^[pb][\da-z]{7}$', value):
506 return value
507 get_from_attributes(item)
508 mediator = item.find('./{%s}mediator' % self._EMP_PLAYLIST_NS)
509 if mediator is not None:
510 return get_from_attributes(mediator)
511
512 programme_id = get_programme_id(item)
513 duration = int_or_none(item.get('duration'))
514
515 if programme_id:
516 formats, subtitles = self._download_media_selector(programme_id)
517 else:
518 formats, subtitles = self._process_media_selector(item, playlist_id)
519 programme_id = playlist_id
520
521 return programme_id, title, description, duration, formats, subtitles
522
523 def _real_extract(self, url):
524 group_id = self._match_id(url)
525
526 webpage = self._download_webpage(url, group_id, 'Downloading video page')
527
528 error = self._search_regex(
529 r'<div\b[^>]+\bclass=["\']smp__message delta["\'][^>]*>([^<]+)<',
530 webpage, 'error', default=None)
531 if error:
532 raise ExtractorError(error, expected=True)
533
534 programme_id = None
535 duration = None
536
537 tviplayer = self._search_regex(
538 r'mediator\.bind\(({.+?})\s*,\s*document\.getElementById',
539 webpage, 'player', default=None)
540
541 if tviplayer:
542 player = self._parse_json(tviplayer, group_id).get('player', {})
543 duration = int_or_none(player.get('duration'))
544 programme_id = player.get('vpid')
545
546 if not programme_id:
547 programme_id = self._search_regex(
548 r'"vpid"\s*:\s*"(%s)"' % self._ID_REGEX, webpage, 'vpid', fatal=False, default=None)
549
550 if programme_id:
551 formats, subtitles = self._download_media_selector(programme_id)
552 title = self._og_search_title(webpage, default=None) or self._html_search_regex(
553 (r'<h2[^>]+id="parent-title"[^>]*>(.+?)</h2>',
554 r'<div[^>]+class="info"[^>]*>\s*<h1>(.+?)</h1>'), webpage, 'title')
555 description = self._search_regex(
556 (r'<p class="[^"]*medium-description[^"]*">([^<]+)</p>',
557 r'<div[^>]+class="info_+synopsis"[^>]*>([^<]+)</div>'),
558 webpage, 'description', default=None)
559 if not description:
560 description = self._html_search_meta('description', webpage)
561 else:
562 programme_id, title, description, duration, formats, subtitles = self._download_playlist(group_id)
563
564 self._sort_formats(formats)
565
566 return {
567 'id': programme_id,
568 'title': title,
569 'description': description,
570 'thumbnail': self._og_search_thumbnail(webpage, default=None),
571 'duration': duration,
572 'formats': formats,
573 'subtitles': subtitles,
574 }
575
576
577 class BBCIE(BBCCoUkIE):
578 IE_NAME = 'bbc'
579 IE_DESC = 'BBC'
580 _VALID_URL = r'https?://(?:www\.)?bbc\.(?:com|co\.uk)/(?:[^/]+/)+(?P<id>[^/#?]+)'
581
582 _MEDIASELECTOR_URLS = [
583 # Provides HQ HLS streams but fails with geolocation in some cases when it's
584 # even not geo restricted at all
585 'http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/iptv-all/vpid/%s',
586 # Provides more formats, namely direct mp4 links, but fails on some videos with
587 # notukerror for non UK (?) users (e.g.
588 # http://www.bbc.com/travel/story/20150625-sri-lankas-spicy-secret)
589 'http://open.live.bbc.co.uk/mediaselector/4/mtis/stream/%s',
590 # Provides fewer formats, but works everywhere for everybody (hopefully)
591 'http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/journalism-pc/vpid/%s',
592 ]
593
594 _TESTS = [{
595 # article with multiple videos embedded with data-playable containing vpids
596 'url': 'http://www.bbc.com/news/world-europe-32668511',
597 'info_dict': {
598 'id': 'world-europe-32668511',
599 'title': 'Russia stages massive WW2 parade despite Western boycott',
600 'description': 'md5:00ff61976f6081841f759a08bf78cc9c',
601 },
602 'playlist_count': 2,
603 }, {
604 # article with multiple videos embedded with data-playable (more videos)
605 'url': 'http://www.bbc.com/news/business-28299555',
606 'info_dict': {
607 'id': 'business-28299555',
608 'title': 'Farnborough Airshow: Video highlights',
609 'description': 'BBC reports and video highlights at the Farnborough Airshow.',
610 },
611 'playlist_count': 9,
612 'skip': 'Save time',
613 }, {
614 # article with multiple videos embedded with `new SMP()`
615 # broken
616 'url': 'http://www.bbc.co.uk/blogs/adamcurtis/entries/3662a707-0af9-3149-963f-47bea720b460',
617 'info_dict': {
618 'id': '3662a707-0af9-3149-963f-47bea720b460',
619 'title': 'BUGGER',
620 },
621 'playlist_count': 18,
622 }, {
623 # single video embedded with data-playable containing vpid
624 'url': 'http://www.bbc.com/news/world-europe-32041533',
625 'info_dict': {
626 'id': 'p02mprgb',
627 'ext': 'mp4',
628 'title': 'Aerial footage showed the site of the crash in the Alps - courtesy BFM TV',
629 'description': 'md5:2868290467291b37feda7863f7a83f54',
630 'duration': 47,
631 'timestamp': 1427219242,
632 'upload_date': '20150324',
633 },
634 'params': {
635 # rtmp download
636 'skip_download': True,
637 }
638 }, {
639 # article with single video embedded with data-playable containing XML playlist
640 # with direct video links as progressiveDownloadUrl (for now these are extracted)
641 # and playlist with f4m and m3u8 as streamingUrl
642 'url': 'http://www.bbc.com/turkce/haberler/2015/06/150615_telabyad_kentin_cogu',
643 'info_dict': {
644 'id': '150615_telabyad_kentin_cogu',
645 'ext': 'mp4',
646 'title': "YPG: Tel Abyad'ın tamamı kontrolümüzde",
647 'description': 'md5:33a4805a855c9baf7115fcbde57e7025',
648 'timestamp': 1434397334,
649 'upload_date': '20150615',
650 },
651 'params': {
652 'skip_download': True,
653 }
654 }, {
655 # single video embedded with data-playable containing XML playlists (regional section)
656 'url': 'http://www.bbc.com/mundo/video_fotos/2015/06/150619_video_honduras_militares_hospitales_corrupcion_aw',
657 'info_dict': {
658 'id': '150619_video_honduras_militares_hospitales_corrupcion_aw',
659 'ext': 'mp4',
660 'title': 'Honduras militariza sus hospitales por nuevo escándalo de corrupción',
661 'description': 'md5:1525f17448c4ee262b64b8f0c9ce66c8',
662 'timestamp': 1434713142,
663 'upload_date': '20150619',
664 },
665 'params': {
666 'skip_download': True,
667 }
668 }, {
669 # single video from video playlist embedded with vxp-playlist-data JSON
670 'url': 'http://www.bbc.com/news/video_and_audio/must_see/33376376',
671 'info_dict': {
672 'id': 'p02w6qjc',
673 'ext': 'mp4',
674 'title': '''Judge Mindy Glazer: "I'm sorry to see you here... I always wondered what happened to you"''',
675 'duration': 56,
676 'description': '''Judge Mindy Glazer: "I'm sorry to see you here... I always wondered what happened to you"''',
677 },
678 'params': {
679 'skip_download': True,
680 }
681 }, {
682 # single video story with digitalData
683 'url': 'http://www.bbc.com/travel/story/20150625-sri-lankas-spicy-secret',
684 'info_dict': {
685 'id': 'p02q6gc4',
686 'ext': 'flv',
687 'title': 'Sri Lanka’s spicy secret',
688 'description': 'As a new train line to Jaffna opens up the country’s north, travellers can experience a truly distinct slice of Tamil culture.',
689 'timestamp': 1437674293,
690 'upload_date': '20150723',
691 },
692 'params': {
693 # rtmp download
694 'skip_download': True,
695 }
696 }, {
697 # single video story without digitalData
698 'url': 'http://www.bbc.com/autos/story/20130513-hyundais-rock-star',
699 'info_dict': {
700 'id': 'p018zqqg',
701 'ext': 'mp4',
702 'title': 'Hyundai Santa Fe Sport: Rock star',
703 'description': 'md5:b042a26142c4154a6e472933cf20793d',
704 'timestamp': 1415867444,
705 'upload_date': '20141113',
706 },
707 'params': {
708 # rtmp download
709 'skip_download': True,
710 }
711 }, {
712 # single video embedded with Morph
713 'url': 'http://www.bbc.co.uk/sport/live/olympics/36895975',
714 'info_dict': {
715 'id': 'p041vhd0',
716 'ext': 'mp4',
717 'title': "Nigeria v Japan - Men's First Round",
718 'description': 'Live coverage of the first round from Group B at the Amazonia Arena.',
719 'duration': 7980,
720 'uploader': 'BBC Sport',
721 'uploader_id': 'bbc_sport',
722 },
723 'params': {
724 # m3u8 download
725 'skip_download': True,
726 },
727 'skip': 'Georestricted to UK',
728 }, {
729 # single video with playlist.sxml URL in playlist param
730 'url': 'http://www.bbc.com/sport/0/football/33653409',
731 'info_dict': {
732 'id': 'p02xycnp',
733 'ext': 'mp4',
734 'title': 'Transfers: Cristiano Ronaldo to Man Utd, Arsenal to spend?',
735 'description': 'BBC Sport\'s David Ornstein has the latest transfer gossip, including rumours of a Manchester United return for Cristiano Ronaldo.',
736 'duration': 140,
737 },
738 'params': {
739 # rtmp download
740 'skip_download': True,
741 }
742 }, {
743 # article with multiple videos embedded with playlist.sxml in playlist param
744 'url': 'http://www.bbc.com/sport/0/football/34475836',
745 'info_dict': {
746 'id': '34475836',
747 'title': 'Jurgen Klopp: Furious football from a witty and winning coach',
748 'description': 'Fast-paced football, wit, wisdom and a ready smile - why Liverpool fans should come to love new boss Jurgen Klopp.',
749 },
750 'playlist_count': 3,
751 }, {
752 # school report article with single video
753 'url': 'http://www.bbc.co.uk/schoolreport/35744779',
754 'info_dict': {
755 'id': '35744779',
756 'title': 'School which breaks down barriers in Jerusalem',
757 },
758 'playlist_count': 1,
759 }, {
760 # single video with playlist URL from weather section
761 'url': 'http://www.bbc.com/weather/features/33601775',
762 'only_matching': True,
763 }, {
764 # custom redirection to www.bbc.com
765 'url': 'http://www.bbc.co.uk/news/science-environment-33661876',
766 'only_matching': True,
767 }, {
768 # single video article embedded with data-media-vpid
769 'url': 'http://www.bbc.co.uk/sport/rowing/35908187',
770 'only_matching': True,
771 }]
772
773 @classmethod
774 def suitable(cls, url):
775 EXCLUDE_IE = (BBCCoUkIE, BBCCoUkArticleIE, BBCCoUkIPlayerPlaylistIE, BBCCoUkPlaylistIE)
776 return (False if any(ie.suitable(url) for ie in EXCLUDE_IE)
777 else super(BBCIE, cls).suitable(url))
778
779 def _extract_from_media_meta(self, media_meta, video_id):
780 # Direct links to media in media metadata (e.g.
781 # http://www.bbc.com/turkce/haberler/2015/06/150615_telabyad_kentin_cogu)
782 # TODO: there are also f4m and m3u8 streams incorporated in playlist.sxml
783 source_files = media_meta.get('sourceFiles')
784 if source_files:
785 return [{
786 'url': f['url'],
787 'format_id': format_id,
788 'ext': f.get('encoding'),
789 'tbr': float_or_none(f.get('bitrate'), 1000),
790 'filesize': int_or_none(f.get('filesize')),
791 } for format_id, f in source_files.items() if f.get('url')], []
792
793 programme_id = media_meta.get('externalId')
794 if programme_id:
795 return self._download_media_selector(programme_id)
796
797 # Process playlist.sxml as legacy playlist
798 href = media_meta.get('href')
799 if href:
800 playlist = self._download_legacy_playlist_url(href)
801 _, _, _, _, formats, subtitles = self._extract_from_legacy_playlist(playlist, video_id)
802 return formats, subtitles
803
804 return [], []
805
806 def _extract_from_playlist_sxml(self, url, playlist_id, timestamp):
807 programme_id, title, description, duration, formats, subtitles = \
808 self._process_legacy_playlist_url(url, playlist_id)
809 self._sort_formats(formats)
810 return {
811 'id': programme_id,
812 'title': title,
813 'description': description,
814 'duration': duration,
815 'timestamp': timestamp,
816 'formats': formats,
817 'subtitles': subtitles,
818 }
819
820 def _real_extract(self, url):
821 playlist_id = self._match_id(url)
822
823 webpage = self._download_webpage(url, playlist_id)
824
825 json_ld_info = self._search_json_ld(webpage, playlist_id, default={})
826 timestamp = json_ld_info.get('timestamp')
827
828 playlist_title = json_ld_info.get('title')
829 if not playlist_title:
830 playlist_title = self._og_search_title(
831 webpage, default=None) or self._html_search_regex(
832 r'<title>(.+?)</title>', webpage, 'playlist title', default=None)
833 if playlist_title:
834 playlist_title = re.sub(r'(.+)\s*-\s*BBC.*?$', r'\1', playlist_title).strip()
835
836 playlist_description = json_ld_info.get(
837 'description') or self._og_search_description(webpage, default=None)
838
839 if not timestamp:
840 timestamp = parse_iso8601(self._search_regex(
841 [r'<meta[^>]+property="article:published_time"[^>]+content="([^"]+)"',
842 r'itemprop="datePublished"[^>]+datetime="([^"]+)"',
843 r'"datePublished":\s*"([^"]+)'],
844 webpage, 'date', default=None))
845
846 entries = []
847
848 # article with multiple videos embedded with playlist.sxml (e.g.
849 # http://www.bbc.com/sport/0/football/34475836)
850 playlists = re.findall(r'<param[^>]+name="playlist"[^>]+value="([^"]+)"', webpage)
851 playlists.extend(re.findall(r'data-media-id="([^"]+/playlist\.sxml)"', webpage))
852 if playlists:
853 entries = [
854 self._extract_from_playlist_sxml(playlist_url, playlist_id, timestamp)
855 for playlist_url in playlists]
856
857 # news article with multiple videos embedded with data-playable
858 data_playables = re.findall(r'data-playable=(["\'])({.+?})\1', webpage)
859 if data_playables:
860 for _, data_playable_json in data_playables:
861 data_playable = self._parse_json(
862 unescapeHTML(data_playable_json), playlist_id, fatal=False)
863 if not data_playable:
864 continue
865 settings = data_playable.get('settings', {})
866 if settings:
867 # data-playable with video vpid in settings.playlistObject.items (e.g.
868 # http://www.bbc.com/news/world-us-canada-34473351)
869 playlist_object = settings.get('playlistObject', {})
870 if playlist_object:
871 items = playlist_object.get('items')
872 if items and isinstance(items, list):
873 title = playlist_object['title']
874 description = playlist_object.get('summary')
875 duration = int_or_none(items[0].get('duration'))
876 programme_id = items[0].get('vpid')
877 formats, subtitles = self._download_media_selector(programme_id)
878 self._sort_formats(formats)
879 entries.append({
880 'id': programme_id,
881 'title': title,
882 'description': description,
883 'timestamp': timestamp,
884 'duration': duration,
885 'formats': formats,
886 'subtitles': subtitles,
887 })
888 else:
889 # data-playable without vpid but with a playlist.sxml URLs
890 # in otherSettings.playlist (e.g.
891 # http://www.bbc.com/turkce/multimedya/2015/10/151010_vid_ankara_patlama_ani)
892 playlist = data_playable.get('otherSettings', {}).get('playlist', {})
893 if playlist:
894 entry = None
895 for key in ('streaming', 'progressiveDownload'):
896 playlist_url = playlist.get('%sUrl' % key)
897 if not playlist_url:
898 continue
899 try:
900 info = self._extract_from_playlist_sxml(
901 playlist_url, playlist_id, timestamp)
902 if not entry:
903 entry = info
904 else:
905 entry['title'] = info['title']
906 entry['formats'].extend(info['formats'])
907 except Exception as e:
908 # Some playlist URL may fail with 500, at the same time
909 # the other one may work fine (e.g.
910 # http://www.bbc.com/turkce/haberler/2015/06/150615_telabyad_kentin_cogu)
911 if isinstance(e.cause, compat_HTTPError) and e.cause.code == 500:
912 continue
913 raise
914 if entry:
915 self._sort_formats(entry['formats'])
916 entries.append(entry)
917
918 if entries:
919 return self.playlist_result(entries, playlist_id, playlist_title, playlist_description)
920
921 # single video story (e.g. http://www.bbc.com/travel/story/20150625-sri-lankas-spicy-secret)
922 programme_id = self._search_regex(
923 [r'data-(?:video-player|media)-vpid="(%s)"' % self._ID_REGEX,
924 r'<param[^>]+name="externalIdentifier"[^>]+value="(%s)"' % self._ID_REGEX,
925 r'videoId\s*:\s*["\'](%s)["\']' % self._ID_REGEX],
926 webpage, 'vpid', default=None)
927
928 if programme_id:
929 formats, subtitles = self._download_media_selector(programme_id)
930 self._sort_formats(formats)
931 # digitalData may be missing (e.g. http://www.bbc.com/autos/story/20130513-hyundais-rock-star)
932 digital_data = self._parse_json(
933 self._search_regex(
934 r'var\s+digitalData\s*=\s*({.+?});?\n', webpage, 'digital data', default='{}'),
935 programme_id, fatal=False)
936 page_info = digital_data.get('page', {}).get('pageInfo', {})
937 title = page_info.get('pageName') or self._og_search_title(webpage)
938 description = page_info.get('description') or self._og_search_description(webpage)
939 timestamp = parse_iso8601(page_info.get('publicationDate')) or timestamp
940 return {
941 'id': programme_id,
942 'title': title,
943 'description': description,
944 'timestamp': timestamp,
945 'formats': formats,
946 'subtitles': subtitles,
947 }
948
949 # Morph based embed (e.g. http://www.bbc.co.uk/sport/live/olympics/36895975)
950 # There are several setPayload calls may be present but the video
951 # seems to be always related to the first one
952 morph_payload = self._parse_json(
953 self._search_regex(
954 r'Morph\.setPayload\([^,]+,\s*({.+?})\);',
955 webpage, 'morph payload', default='{}'),
956 playlist_id, fatal=False)
957 if morph_payload:
958 components = try_get(morph_payload, lambda x: x['body']['components'], list) or []
959 for component in components:
960 if not isinstance(component, dict):
961 continue
962 lead_media = try_get(component, lambda x: x['props']['leadMedia'], dict)
963 if not lead_media:
964 continue
965 identifiers = lead_media.get('identifiers')
966 if not identifiers or not isinstance(identifiers, dict):
967 continue
968 programme_id = identifiers.get('vpid') or identifiers.get('playablePid')
969 if not programme_id:
970 continue
971 title = lead_media.get('title') or self._og_search_title(webpage)
972 formats, subtitles = self._download_media_selector(programme_id)
973 self._sort_formats(formats)
974 description = lead_media.get('summary')
975 uploader = lead_media.get('masterBrand')
976 uploader_id = lead_media.get('mid')
977 duration = None
978 duration_d = lead_media.get('duration')
979 if isinstance(duration_d, dict):
980 duration = parse_duration(dict_get(
981 duration_d, ('rawDuration', 'formattedDuration', 'spokenDuration')))
982 return {
983 'id': programme_id,
984 'title': title,
985 'description': description,
986 'duration': duration,
987 'uploader': uploader,
988 'uploader_id': uploader_id,
989 'formats': formats,
990 'subtitles': subtitles,
991 }
992
993 def extract_all(pattern):
994 return list(filter(None, map(
995 lambda s: self._parse_json(s, playlist_id, fatal=False),
996 re.findall(pattern, webpage))))
997
998 # Multiple video article (e.g.
999 # http://www.bbc.co.uk/blogs/adamcurtis/entries/3662a707-0af9-3149-963f-47bea720b460)
1000 EMBED_URL = r'https?://(?:www\.)?bbc\.co\.uk/(?:[^/]+/)+%s(?:\b[^"]+)?' % self._ID_REGEX
1001 entries = []
1002 for match in extract_all(r'new\s+SMP\(({.+?})\)'):
1003 embed_url = match.get('playerSettings', {}).get('externalEmbedUrl')
1004 if embed_url and re.match(EMBED_URL, embed_url):
1005 entries.append(embed_url)
1006 entries.extend(re.findall(
1007 r'setPlaylist\("(%s)"\)' % EMBED_URL, webpage))
1008 if entries:
1009 return self.playlist_result(
1010 [self.url_result(entry_, 'BBCCoUk') for entry_ in entries],
1011 playlist_id, playlist_title, playlist_description)
1012
1013 # Multiple video article (e.g. http://www.bbc.com/news/world-europe-32668511)
1014 medias = extract_all(r"data-media-meta='({[^']+})'")
1015
1016 if not medias:
1017 # Single video article (e.g. http://www.bbc.com/news/video_and_audio/international)
1018 media_asset = self._search_regex(
1019 r'mediaAssetPage\.init\(\s*({.+?}), "/',
1020 webpage, 'media asset', default=None)
1021 if media_asset:
1022 media_asset_page = self._parse_json(media_asset, playlist_id, fatal=False)
1023 medias = []
1024 for video in media_asset_page.get('videos', {}).values():
1025 medias.extend(video.values())
1026
1027 if not medias:
1028 # Multiple video playlist with single `now playing` entry (e.g.
1029 # http://www.bbc.com/news/video_and_audio/must_see/33767813)
1030 vxp_playlist = self._parse_json(
1031 self._search_regex(
1032 r'<script[^>]+class="vxp-playlist-data"[^>]+type="application/json"[^>]*>([^<]+)</script>',
1033 webpage, 'playlist data'),
1034 playlist_id)
1035 playlist_medias = []
1036 for item in vxp_playlist:
1037 media = item.get('media')
1038 if not media:
1039 continue
1040 playlist_medias.append(media)
1041 # Download single video if found media with asset id matching the video id from URL
1042 if item.get('advert', {}).get('assetId') == playlist_id:
1043 medias = [media]
1044 break
1045 # Fallback to the whole playlist
1046 if not medias:
1047 medias = playlist_medias
1048
1049 entries = []
1050 for num, media_meta in enumerate(medias, start=1):
1051 formats, subtitles = self._extract_from_media_meta(media_meta, playlist_id)
1052 if not formats:
1053 continue
1054 self._sort_formats(formats)
1055
1056 video_id = media_meta.get('externalId')
1057 if not video_id:
1058 video_id = playlist_id if len(medias) == 1 else '%s-%s' % (playlist_id, num)
1059
1060 title = media_meta.get('caption')
1061 if not title:
1062 title = playlist_title if len(medias) == 1 else '%s - Video %s' % (playlist_title, num)
1063
1064 duration = int_or_none(media_meta.get('durationInSeconds')) or parse_duration(media_meta.get('duration'))
1065
1066 images = []
1067 for image in media_meta.get('images', {}).values():
1068 images.extend(image.values())
1069 if 'image' in media_meta:
1070 images.append(media_meta['image'])
1071
1072 thumbnails = [{
1073 'url': image.get('href'),
1074 'width': int_or_none(image.get('width')),
1075 'height': int_or_none(image.get('height')),
1076 } for image in images]
1077
1078 entries.append({
1079 'id': video_id,
1080 'title': title,
1081 'thumbnails': thumbnails,
1082 'duration': duration,
1083 'timestamp': timestamp,
1084 'formats': formats,
1085 'subtitles': subtitles,
1086 })
1087
1088 return self.playlist_result(entries, playlist_id, playlist_title, playlist_description)
1089
1090
1091 class BBCCoUkArticleIE(InfoExtractor):
1092 _VALID_URL = r'https?://(?:www\.)?bbc\.co\.uk/programmes/articles/(?P<id>[a-zA-Z0-9]+)'
1093 IE_NAME = 'bbc.co.uk:article'
1094 IE_DESC = 'BBC articles'
1095
1096 _TEST = {
1097 'url': 'http://www.bbc.co.uk/programmes/articles/3jNQLTMrPlYGTBn0WV6M2MS/not-your-typical-role-model-ada-lovelace-the-19th-century-programmer',
1098 'info_dict': {
1099 'id': '3jNQLTMrPlYGTBn0WV6M2MS',
1100 'title': 'Calculating Ada: The Countess of Computing - Not your typical role model: Ada Lovelace the 19th century programmer - BBC Four',
1101 'description': 'Hannah Fry reveals some of her surprising discoveries about Ada Lovelace during filming.',
1102 },
1103 'playlist_count': 4,
1104 'add_ie': ['BBCCoUk'],
1105 }
1106
1107 def _real_extract(self, url):
1108 playlist_id = self._match_id(url)
1109
1110 webpage = self._download_webpage(url, playlist_id)
1111
1112 title = self._og_search_title(webpage)
1113 description = self._og_search_description(webpage).strip()
1114
1115 entries = [self.url_result(programme_url) for programme_url in re.findall(
1116 r'<div[^>]+typeof="Clip"[^>]+resource="([^"]+)"', webpage)]
1117
1118 return self.playlist_result(entries, playlist_id, title, description)
1119
1120
1121 class BBCCoUkPlaylistBaseIE(InfoExtractor):
1122 def _entries(self, webpage, url, playlist_id):
1123 single_page = 'page' in compat_urlparse.parse_qs(
1124 compat_urlparse.urlparse(url).query)
1125 for page_num in itertools.count(2):
1126 for video_id in re.findall(
1127 self._VIDEO_ID_TEMPLATE % BBCCoUkIE._ID_REGEX, webpage):
1128 yield self.url_result(
1129 self._URL_TEMPLATE % video_id, BBCCoUkIE.ie_key())
1130 if single_page:
1131 return
1132 next_page = self._search_regex(
1133 r'<li[^>]+class=(["\'])pagination_+next\1[^>]*><a[^>]+href=(["\'])(?P<url>(?:(?!\2).)+)\2',
1134 webpage, 'next page url', default=None, group='url')
1135 if not next_page:
1136 break
1137 webpage = self._download_webpage(
1138 compat_urlparse.urljoin(url, next_page), playlist_id,
1139 'Downloading page %d' % page_num, page_num)
1140
1141 def _real_extract(self, url):
1142 playlist_id = self._match_id(url)
1143
1144 webpage = self._download_webpage(url, playlist_id)
1145
1146 title, description = self._extract_title_and_description(webpage)
1147
1148 return self.playlist_result(
1149 self._entries(webpage, url, playlist_id),
1150 playlist_id, title, description)
1151
1152
1153 class BBCCoUkIPlayerPlaylistIE(BBCCoUkPlaylistBaseIE):
1154 IE_NAME = 'bbc.co.uk:iplayer:playlist'
1155 _VALID_URL = r'https?://(?:www\.)?bbc\.co\.uk/iplayer/(?:episodes|group)/(?P<id>%s)' % BBCCoUkIE._ID_REGEX
1156 _URL_TEMPLATE = 'http://www.bbc.co.uk/iplayer/episode/%s'
1157 _VIDEO_ID_TEMPLATE = r'data-ip-id=["\'](%s)'
1158 _TESTS = [{
1159 'url': 'http://www.bbc.co.uk/iplayer/episodes/b05rcz9v',
1160 'info_dict': {
1161 'id': 'b05rcz9v',
1162 'title': 'The Disappearance',
1163 'description': 'French thriller serial about a missing teenager.',
1164 },
1165 'playlist_mincount': 6,
1166 'skip': 'This programme is not currently available on BBC iPlayer',
1167 }, {
1168 # Available for over a year unlike 30 days for most other programmes
1169 'url': 'http://www.bbc.co.uk/iplayer/group/p02tcc32',
1170 'info_dict': {
1171 'id': 'p02tcc32',
1172 'title': 'Bohemian Icons',
1173 'description': 'md5:683e901041b2fe9ba596f2ab04c4dbe7',
1174 },
1175 'playlist_mincount': 10,
1176 }]
1177
1178 def _extract_title_and_description(self, webpage):
1179 title = self._search_regex(r'<h1>([^<]+)</h1>', webpage, 'title', fatal=False)
1180 description = self._search_regex(
1181 r'<p[^>]+class=(["\'])subtitle\1[^>]*>(?P<value>[^<]+)</p>',
1182 webpage, 'description', fatal=False, group='value')
1183 return title, description
1184
1185
1186 class BBCCoUkPlaylistIE(BBCCoUkPlaylistBaseIE):
1187 IE_NAME = 'bbc.co.uk:playlist'
1188 _VALID_URL = r'https?://(?:www\.)?bbc\.co\.uk/programmes/(?P<id>%s)/(?:episodes|broadcasts|clips)' % BBCCoUkIE._ID_REGEX
1189 _URL_TEMPLATE = 'http://www.bbc.co.uk/programmes/%s'
1190 _VIDEO_ID_TEMPLATE = r'data-pid=["\'](%s)'
1191 _TESTS = [{
1192 'url': 'http://www.bbc.co.uk/programmes/b05rcz9v/clips',
1193 'info_dict': {
1194 'id': 'b05rcz9v',
1195 'title': 'The Disappearance - Clips - BBC Four',
1196 'description': 'French thriller serial about a missing teenager.',
1197 },
1198 'playlist_mincount': 7,
1199 }, {
1200 # multipage playlist, explicit page
1201 'url': 'http://www.bbc.co.uk/programmes/b00mfl7n/clips?page=1',
1202 'info_dict': {
1203 'id': 'b00mfl7n',
1204 'title': 'Frozen Planet - Clips - BBC One',
1205 'description': 'md5:65dcbf591ae628dafe32aa6c4a4a0d8c',
1206 },
1207 'playlist_mincount': 24,
1208 }, {
1209 # multipage playlist, all pages
1210 'url': 'http://www.bbc.co.uk/programmes/b00mfl7n/clips',
1211 'info_dict': {
1212 'id': 'b00mfl7n',
1213 'title': 'Frozen Planet - Clips - BBC One',
1214 'description': 'md5:65dcbf591ae628dafe32aa6c4a4a0d8c',
1215 },
1216 'playlist_mincount': 142,
1217 }, {
1218 'url': 'http://www.bbc.co.uk/programmes/b05rcz9v/broadcasts/2016/06',
1219 'only_matching': True,
1220 }, {
1221 'url': 'http://www.bbc.co.uk/programmes/b05rcz9v/clips',
1222 'only_matching': True,
1223 }, {
1224 'url': 'http://www.bbc.co.uk/programmes/b055jkys/episodes/player',
1225 'only_matching': True,
1226 }]
1227
1228 def _extract_title_and_description(self, webpage):
1229 title = self._og_search_title(webpage, fatal=False)
1230 description = self._og_search_description(webpage)
1231 return title, description