2 from __future__
import unicode_literals
9 from .common
import InfoExtractor
10 from ..compat
import (
14 compat_urllib_parse_urlparse
,
36 class BBCCoUkIE(InfoExtractor
):
38 IE_DESC
= 'BBC iPlayer'
39 _ID_REGEX
= r
'(?:[pbm][\da-z]{7}|w[\da-z]{7,14})'
42 (?:www\.)?bbc\.co\.uk/
44 programmes/(?!articles/)|
45 iplayer(?:/[^/]+)?/(?:episode/|playlist/)|
46 music/(?:clips|audiovideo/popular)[/#]|
49 events/[^/]+/play/[^/]+/
51 (?P<id>%s)(?!/(?:episodes|broadcasts|clips))
54 _LOGIN_URL
= 'https://account.bbc.com/signin'
55 _NETRC_MACHINE
= 'bbc'
57 _MEDIA_SELECTOR_URL_TEMPL
= 'https://open.live.bbc.co.uk/mediaselector/6/select/version/2.0/mediaset/%s/vpid/%s'
59 # Provides HQ HLS streams with even better quality that pc mediaset but fails
60 # with geolocation in some cases when it's even not geo restricted at all (e.g.
61 # http://www.bbc.co.uk/programmes/b06bp7lf). Also may fail with selectionunavailable.
66 _EMP_PLAYLIST_NS
= 'http://bbc.co.uk/2008/emp/playlist'
70 'url': 'http://www.bbc.co.uk/programmes/b039g8p7',
74 'title': 'Kaleidoscope, Leonard Cohen',
75 'description': 'The Canadian poet and songwriter reflects on his musical career.',
79 'skip_download': True,
83 'url': 'http://www.bbc.co.uk/iplayer/episode/b00yng5w/The_Man_in_Black_Series_3_The_Printed_Name/',
87 'title': 'The Man in Black: Series 3: The Printed Name',
88 'description': "Mark Gatiss introduces Nicholas Pierpan's chilling tale of a writer's devilish pact with a mysterious man. Stars Ewan Bailey.",
93 'skip_download': True,
95 'skip': 'Episode is no longer available on BBC iPlayer Radio',
98 'url': 'http://www.bbc.co.uk/iplayer/episode/b03vhd1f/The_Voice_UK_Series_3_Blind_Auditions_5/',
102 'title': 'The Voice UK: Series 3: Blind Auditions 5',
103 '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.',
108 'skip_download': True,
110 'skip': 'Currently BBC iPlayer TV programmes are available to play in the UK only',
113 'url': 'http://www.bbc.co.uk/iplayer/episode/p026c7jt/tomorrows-worlds-the-unearthly-history-of-science-fiction-2-invasion',
117 'title': "Tomorrow's Worlds: The Unearthly History of Science Fiction",
118 'description': '2. Invasion',
123 'skip_download': True,
125 'skip': 'Currently BBC iPlayer TV programmes are available to play in the UK only',
127 'url': 'http://www.bbc.co.uk/programmes/b04v20dw',
131 'title': 'Pete Tong, The Essential New Tune Special',
132 'description': "Pete has a very special mix - all of 2014's Essential New Tunes!",
137 'skip_download': True,
139 'skip': 'Episode is no longer available on BBC iPlayer Radio',
141 'url': 'http://www.bbc.co.uk/music/clips/p022h44b',
146 'title': 'BBC Proms Music Guides, Rachmaninov: Symphonic Dances',
147 'description': "In this Proms Music Guide, Andrew McGregor looks at Rachmaninov's Symphonic Dances.",
152 'skip_download': True,
155 'url': 'http://www.bbc.co.uk/music/clips/p025c0zz',
160 'title': 'Reading and Leeds Festival, 2014, Rae Morris - Closer (Live on BBC Three)',
161 'description': 'Rae Morris performs Closer for BBC Three at Reading 2014',
166 'skip_download': True,
169 'url': 'http://www.bbc.co.uk/iplayer/episode/b054fn09/ad/natural-world-20152016-2-super-powered-owls',
173 'title': 'Natural World, 2015-2016: 2. Super Powered Owls',
174 'description': 'md5:e4db5c937d0e95a7c6b5e654d429183d',
179 'skip_download': True,
181 'skip': 'geolocation',
183 'url': 'http://www.bbc.co.uk/iplayer/episode/b05zmgwn/royal-academy-summer-exhibition',
187 '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.',
188 'title': 'Royal Academy Summer Exhibition',
193 'skip_download': True,
195 'skip': 'geolocation',
197 # iptv-all mediaset fails with geolocation however there is no geo restriction
198 # for this programme at all
199 'url': 'http://www.bbc.co.uk/programmes/b06rkn85',
203 'title': "Best of the Mini-Mixes 2015: Part 3, Annie Mac's Friday Night - BBC Radio 1",
204 'description': "Annie has part three in the Best of the Mini-Mixes 2015, plus the year's Most Played!",
208 'skip_download': True,
210 'skip': 'Now it\'s really geo-restricted',
212 # compact player (https://github.com/ytdl-org/youtube-dl/issues/8147)
213 'url': 'http://www.bbc.co.uk/programmes/p028bfkf/player',
217 'title': 'Extract from BBC documentary Look Stranger - Giant Leeks and Magic Brews',
218 'description': 'Extract from BBC documentary Look Stranger - Giant Leeks and Magic Brews',
222 'skip_download': True,
225 'url': 'https://www.bbc.co.uk/sounds/play/m0007jzb',
230 'title': 'BBC Proms, 2019, Prom 34: West–Eastern Divan Orchestra',
231 'description': "Live BBC Proms. West–Eastern Divan Orchestra with Daniel Barenboim and Martha Argerich.",
236 'skip_download': True,
239 'url': 'http://www.bbc.co.uk/iplayer/playlist/p01dvks4',
240 'only_matching': True,
242 'url': 'http://www.bbc.co.uk/music/clips#p02frcc3',
243 'only_matching': True,
245 'url': 'http://www.bbc.co.uk/iplayer/cbeebies/episode/b0480276/bing-14-atchoo',
246 'only_matching': True,
248 'url': 'http://www.bbc.co.uk/radio/player/p03cchwf',
249 'only_matching': True,
251 'url': 'https://www.bbc.co.uk/music/audiovideo/popular#p055bc55',
252 'only_matching': True,
254 'url': 'http://www.bbc.co.uk/programmes/w3csv1y9',
255 'only_matching': True,
257 'url': 'https://www.bbc.co.uk/programmes/m00005xn',
258 'only_matching': True,
260 'url': 'https://www.bbc.co.uk/programmes/w172w4dww1jqt5s',
261 'only_matching': True,
265 username
, password
= self
._get
_login
_info
()
269 login_page
= self
._download
_webpage
(
270 self
._LOGIN
_URL
, None, 'Downloading signin page')
272 login_form
= self
._hidden
_inputs
(login_page
)
275 'username': username
,
276 'password': password
,
279 post_url
= urljoin(self
._LOGIN
_URL
, self
._search
_regex
(
280 r
'<form[^>]+action=(["\'])(?P
<url
>.+?
)\
1', login_page,
281 'post url
', default=self._LOGIN_URL, group='url
'))
283 response, urlh = self._download_webpage_handle(
284 post_url, None, 'Logging
in', data=urlencode_postdata(login_form),
285 headers={'Referer': self._LOGIN_URL})
287 if self._LOGIN_URL in urlh.geturl():
288 error = clean_html(get_element_by_class('form
-message
', response))
290 raise ExtractorError(
291 'Unable to login
: %s' % error, expected=True)
292 raise ExtractorError('Unable to log
in')
294 def _real_initialize(self):
297 class MediaSelectionError(Exception):
298 def __init__(self, id):
301 def _extract_asx_playlist(self, connection, programme_id):
302 asx = self._download_xml(connection.get('href
'), programme_id, 'Downloading ASX playlist
')
303 return [ref.get('href
') for ref in asx.findall('./Entry
/ref
')]
305 def _extract_items(self, playlist):
306 return playlist.findall('./{%s}item
' % self._EMP_PLAYLIST_NS)
308 def _extract_medias(self, media_selection):
309 error = media_selection.get('result
')
311 raise BBCCoUkIE.MediaSelectionError(error)
312 return media_selection.get('media
') or []
314 def _extract_connections(self, media):
315 return media.get('connection
') or []
317 def _get_subtitles(self, media, programme_id):
319 for connection in self._extract_connections(media):
320 cc_url = url_or_none(connection.get('href
'))
323 captions = self._download_xml(
324 cc_url, programme_id, 'Downloading captions
', fatal=False)
325 if not isinstance(captions, compat_etree_Element):
329 'url
': connection.get('href
'),
336 def _raise_extractor_error(self, media_selection_error):
337 raise ExtractorError(
338 '%s returned error
: %s' % (self.IE_NAME, media_selection_error.id),
341 def _download_media_selector(self, programme_id):
342 last_exception = None
343 for media_set in self._MEDIA_SETS:
345 return self._download_media_selector_url(
346 self._MEDIA_SELECTOR_URL_TEMPL % (media_set, programme_id), programme_id)
347 except BBCCoUkIE.MediaSelectionError as e:
348 if e.id in ('notukerror
', 'geolocation
', 'selectionunavailable
'):
351 self._raise_extractor_error(e)
352 self._raise_extractor_error(last_exception)
354 def _download_media_selector_url(self, url, programme_id=None):
355 media_selection = self._download_json(
356 url, programme_id, 'Downloading media selection JSON
',
357 expected_status=(403, 404))
358 return self._process_media_selector(media_selection, programme_id)
360 def _process_media_selector(self, media_selection, programme_id):
365 for media in self._extract_medias(media_selection):
366 kind = media.get('kind
')
367 if kind in ('video
', 'audio
'):
368 bitrate = int_or_none(media.get('bitrate
'))
369 encoding = media.get('encoding
')
370 width = int_or_none(media.get('width
'))
371 height = int_or_none(media.get('height
'))
372 file_size = int_or_none(media.get('media_file_size
'))
373 for connection in self._extract_connections(media):
374 href = connection.get('href
')
379 conn_kind = connection.get('kind
')
380 protocol = connection.get('protocol
')
381 supplier = connection.get('supplier
')
382 transfer_format = connection.get('transferFormat
')
383 format_id = supplier or conn_kind or protocol
385 if supplier == 'asx
':
386 for i, ref in enumerate(self._extract_asx_playlist(connection, programme_id)):
389 'format_id
': 'ref
%s_%s' % (i, format_id),
391 elif transfer_format == 'dash
':
392 formats.extend(self._extract_mpd_formats(
393 href, programme_id, mpd_id=format_id, fatal=False))
394 elif transfer_format == 'hls
':
395 formats.extend(self._extract_m3u8_formats(
396 href, programme_id, ext='mp4
', entry_protocol='m3u8_native
',
397 m3u8_id=format_id, fatal=False))
398 elif transfer_format == 'hds
':
399 formats.extend(self._extract_f4m_formats(
400 href, programme_id, f4m_id=format_id, fatal=False))
402 if not supplier and bitrate:
403 format_id += '-%d' % bitrate
405 'format_id
': format_id,
406 'filesize
': file_size,
421 if protocol in ('http
', 'https
'):
426 elif protocol == 'rtmp
':
427 application = connection.get('application
', 'ondemand
')
428 auth_string = connection.get('authString
')
429 identifier = connection.get('identifier
')
430 server = connection.get('server
')
432 'url
': '%s://%s/%s?
%s' % (protocol, server, application, auth_string),
433 'play_path
': identifier,
434 'app
': '%s?
%s' % (application, auth_string),
435 'page_url
': 'http
://www
.bbc
.co
.uk
',
436 'player_url
': 'http
://www
.bbc
.co
.uk
/emp
/releases
/iplayer
/revisions
/617463_618125_4/617463_618125_4_emp
.swf
',
443 elif kind == 'captions
':
444 subtitles = self.extract_subtitles(media, programme_id)
445 return formats, subtitles
447 def _download_playlist(self, playlist_id):
449 playlist = self._download_json(
450 'http
://www
.bbc
.co
.uk
/programmes
/%s/playlist
.json
' % playlist_id,
451 playlist_id, 'Downloading playlist JSON
')
453 version = playlist.get('defaultAvailableVersion
')
455 smp_config = version['smpConfig
']
456 title = smp_config['title
']
457 description = smp_config['summary
']
458 for item in smp_config['items
']:
460 if kind not in ('programme
', 'radioProgramme
'):
462 programme_id = item.get('vpid
')
463 duration = int_or_none(item.get('duration
'))
464 formats, subtitles = self._download_media_selector(programme_id)
465 return programme_id, title, description, duration, formats, subtitles
466 except ExtractorError as ee:
467 if not (isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 404):
470 # fallback to legacy playlist
471 return self._process_legacy_playlist(playlist_id)
473 def _process_legacy_playlist_url(self, url, display_id):
474 playlist = self._download_legacy_playlist_url(url, display_id)
475 return self._extract_from_legacy_playlist(playlist, display_id)
477 def _process_legacy_playlist(self, playlist_id):
478 return self._process_legacy_playlist_url(
479 'http
://www
.bbc
.co
.uk
/iplayer
/playlist
/%s' % playlist_id, playlist_id)
481 def _download_legacy_playlist_url(self, url, playlist_id=None):
482 return self._download_xml(
483 url, playlist_id, 'Downloading legacy playlist XML
')
485 def _extract_from_legacy_playlist(self, playlist, playlist_id):
486 no_items = playlist.find('./{%s}noItems
' % self._EMP_PLAYLIST_NS)
487 if no_items is not None:
488 reason = no_items.get('reason
')
489 if reason == 'preAvailability
':
490 msg = 'Episode
%s is not yet available
' % playlist_id
491 elif reason == 'postAvailability
':
492 msg = 'Episode
%s is no longer available
' % playlist_id
493 elif reason == 'noMedia
':
494 msg = 'Episode
%s is not currently available
' % playlist_id
496 msg = 'Episode
%s is not available
: %s' % (playlist_id, reason)
497 raise ExtractorError(msg, expected=True)
499 for item in self._extract_items(playlist):
500 kind = item.get('kind
')
501 if kind not in ('programme
', 'radioProgramme
'):
503 title = playlist.find('./{%s}title
' % self._EMP_PLAYLIST_NS).text
504 description_el = playlist.find('./{%s}summary
' % self._EMP_PLAYLIST_NS)
505 description = description_el.text if description_el is not None else None
507 def get_programme_id(item):
508 def get_from_attributes(item):
509 for p in ('identifier
', 'group
'):
511 if value and re.match(r'^
[pb
][\da
-z
]{7}$
', value):
513 get_from_attributes(item)
514 mediator = item.find('./{%s}mediator
' % self._EMP_PLAYLIST_NS)
515 if mediator is not None:
516 return get_from_attributes(mediator)
518 programme_id = get_programme_id(item)
519 duration = int_or_none(item.get('duration
'))
522 formats, subtitles = self._download_media_selector(programme_id)
524 formats, subtitles = self._process_media_selector(item, playlist_id)
525 programme_id = playlist_id
527 return programme_id, title, description, duration, formats, subtitles
529 def _real_extract(self, url):
530 group_id = self._match_id(url)
532 webpage = self._download_webpage(url, group_id, 'Downloading video page
')
534 error = self._search_regex(
535 r'<div
\b[^
>]+\bclass
=["\'](?:smp|playout)__message delta["\'][^
>]*>\s
*([^
<]+?
)\s
*<',
536 webpage, 'error
', default=None)
538 raise ExtractorError(error, expected=True)
543 tviplayer = self._search_regex(
544 r'mediator\
.bind\
(({.+?}
)\s
*,\s
*document\
.getElementById
',
545 webpage, 'player
', default=None)
548 player = self._parse_json(tviplayer, group_id).get('player
', {})
549 duration = int_or_none(player.get('duration
'))
550 programme_id = player.get('vpid
')
553 programme_id = self._search_regex(
554 r'"vpid"\s
*:\s
*"(%s)"' % self._ID_REGEX, webpage, 'vpid
', fatal=False, default=None)
557 formats, subtitles = self._download_media_selector(programme_id)
558 title = self._og_search_title(webpage, default=None) or self._html_search_regex(
559 (r'<h2
[^
>]+id="parent-title"[^
>]*>(.+?
)</h2
>',
560 r'<div
[^
>]+class="info"[^
>]*>\s
*<h1
>(.+?
)</h1
>'), webpage, 'title
')
561 description = self._search_regex(
562 (r'<p
class="[^"]*medium
-description
[^
"]*">([^
<]+)</p
>',
563 r'<div
[^
>]+class="info_+synopsis"[^
>]*>([^
<]+)</div
>'),
564 webpage, 'description
', default=None)
566 description = self._html_search_meta('description
', webpage)
568 programme_id, title, description, duration, formats, subtitles = self._download_playlist(group_id)
570 self._sort_formats(formats)
575 'description
': description,
576 'thumbnail
': self._og_search_thumbnail(webpage, default=None),
577 'duration
': duration,
579 'subtitles
': subtitles,
583 class BBCIE(BBCCoUkIE):
586 _VALID_URL = r'https?
://(?
:www\
.)?bbc\
.(?
:com|co\
.uk
)/(?
:[^
/]+/)+(?P
<id>[^
/#?]+)'
589 'mobile-tablet-main',
594 # article with multiple videos embedded with data-playable containing vpids
595 'url': 'http://www.bbc.com/news/world-europe-32668511',
597 'id': 'world-europe-32668511',
598 'title': 'Russia stages massive WW2 parade',
599 'description': 'md5:00ff61976f6081841f759a08bf78cc9c',
603 # article with multiple videos embedded with data-playable (more videos)
604 'url': 'http://www.bbc.com/news/business-28299555',
606 'id': 'business-28299555',
607 'title': 'Farnborough Airshow: Video highlights',
608 'description': 'BBC reports and video highlights at the Farnborough Airshow.',
613 # article with multiple videos embedded with `new SMP()`
615 'url': 'http://www.bbc.co.uk/blogs/adamcurtis/entries/3662a707-0af9-3149-963f-47bea720b460',
617 'id': '3662a707-0af9-3149-963f-47bea720b460',
620 'playlist_count': 18,
622 # single video embedded with data-playable containing vpid
623 'url': 'http://www.bbc.com/news/world-europe-32041533',
627 'title': 'Aerial footage showed the site of the crash in the Alps - courtesy BFM TV',
628 'description': 'md5:2868290467291b37feda7863f7a83f54',
630 'timestamp': 1427219242,
631 'upload_date': '20150324',
635 'skip_download': True,
638 # article with single video embedded with data-playable containing XML playlist
639 # with direct video links as progressiveDownloadUrl (for now these are extracted)
640 # and playlist with f4m and m3u8 as streamingUrl
641 'url': 'http://www.bbc.com/turkce/haberler/2015/06/150615_telabyad_kentin_cogu',
643 'id': '150615_telabyad_kentin_cogu',
645 'title': "YPG: Tel Abyad'ın tamamı kontrolümüzde",
646 'description': 'md5:33a4805a855c9baf7115fcbde57e7025',
647 'timestamp': 1434397334,
648 'upload_date': '20150615',
651 'skip_download': True,
654 # single video embedded with data-playable containing XML playlists (regional section)
655 'url': 'http://www.bbc.com/mundo/video_fotos/2015/06/150619_video_honduras_militares_hospitales_corrupcion_aw',
657 'id': '150619_video_honduras_militares_hospitales_corrupcion_aw',
659 'title': 'Honduras militariza sus hospitales por nuevo escándalo de corrupción',
660 'description': 'md5:1525f17448c4ee262b64b8f0c9ce66c8',
661 'timestamp': 1434713142,
662 'upload_date': '20150619',
665 'skip_download': True,
668 # single video from video playlist embedded with vxp-playlist-data JSON
669 'url': 'http://www.bbc.com/news/video_and_audio/must_see/33376376',
673 'title': '''Judge Mindy Glazer: "I'm sorry to see you here... I always wondered what happened to you"''',
675 'description': '''Judge Mindy Glazer: "I'm sorry to see you here... I always wondered what happened to you"''',
678 'skip_download': True,
681 # single video story with digitalData
682 'url': 'http://www.bbc.com/travel/story/20150625-sri-lankas-spicy-secret',
686 'title': 'Sri Lanka’s spicy secret',
687 'description': 'As a new train line to Jaffna opens up the country’s north, travellers can experience a truly distinct slice of Tamil culture.',
688 'timestamp': 1437674293,
689 'upload_date': '20150723',
693 'skip_download': True,
696 # single video story without digitalData
697 'url': 'http://www.bbc.com/autos/story/20130513-hyundais-rock-star',
701 'title': 'Hyundai Santa Fe Sport: Rock star',
702 'description': 'md5:b042a26142c4154a6e472933cf20793d',
703 'timestamp': 1415867444,
704 'upload_date': '20141113',
708 'skip_download': True,
711 # single video embedded with Morph
712 'url': 'http://www.bbc.co.uk/sport/live/olympics/36895975',
716 'title': "Nigeria v Japan - Men's First Round",
717 'description': 'Live coverage of the first round from Group B at the Amazonia Arena.',
719 'uploader': 'BBC Sport',
720 'uploader_id': 'bbc_sport',
724 'skip_download': True,
726 'skip': 'Georestricted to UK',
728 # single video with playlist.sxml URL in playlist param
729 'url': 'http://www.bbc.com/sport/0/football/33653409',
733 'title': 'Transfers: Cristiano Ronaldo to Man Utd, Arsenal to spend?',
734 'description': 'BBC Sport\'s David Ornstein has the latest transfer gossip, including rumours of a Manchester United return for Cristiano Ronaldo.',
739 'skip_download': True,
742 # article with multiple videos embedded with playlist.sxml in playlist param
743 'url': 'http://www.bbc.com/sport/0/football/34475836',
746 'title': 'Jurgen Klopp: Furious football from a witty and winning coach',
747 'description': 'Fast-paced football, wit, wisdom and a ready smile - why Liverpool fans should come to love new boss Jurgen Klopp.',
751 # school report article with single video
752 'url': 'http://www.bbc.co.uk/schoolreport/35744779',
755 'title': 'School which breaks down barriers in Jerusalem',
759 # single video with playlist URL from weather section
760 'url': 'http://www.bbc.com/weather/features/33601775',
761 'only_matching': True,
763 # custom redirection to www.bbc.com
764 'url': 'http://www.bbc.co.uk/news/science-environment-33661876',
765 'only_matching': True,
767 # single video article embedded with data-media-vpid
768 'url': 'http://www.bbc.co.uk/sport/rowing/35908187',
769 'only_matching': True,
771 'url': 'https://www.bbc.co.uk/bbcthree/clip/73d0bbd0-abc3-4cea-b3c0-cdae21905eb1',
775 'title': 'Transfers: Cristiano Ronaldo to Man Utd, Arsenal to spend?',
776 'description': 'md5:4b7dfd063d5a789a1512e99662be3ddd',
779 'skip_download': True,
782 # window.__PRELOADED_STATE__
783 'url': 'https://www.bbc.co.uk/radio/play/b0b9z4yl',
787 'title': 'Prom 6: An American in Paris and Turangalila',
788 'description': 'md5:51cf7d6f5c8553f197e58203bc78dff8',
789 'uploader': 'Radio 3',
790 'uploader_id': 'bbc_radio_three',
793 'url': 'http://www.bbc.co.uk/learningenglish/chinese/features/lingohack/ep-181227',
797 'title': 'md5:2fabf12a726603193a2879a055f72514',
798 'description': 'Learn English words and phrases from this story',
800 'add_ie': [BBCCoUkIE
.ie_key()],
803 'url': 'https://www.bbc.com/reel/video/p07c6sb6/how-positive-thinking-is-harming-your-happiness',
807 'title': 'How positive thinking is harming your happiness',
808 'alt_title': 'The downsides of positive thinking',
809 'description': 'md5:fad74b31da60d83b8265954ee42d85b4',
811 'thumbnail': r
're:https?://.+/p07c9dsr.jpg',
812 'upload_date': '20190604',
813 'categories': ['Psychology'],
818 def suitable(cls
, url
):
819 EXCLUDE_IE
= (BBCCoUkIE
, BBCCoUkArticleIE
, BBCCoUkIPlayerEpisodesIE
, BBCCoUkIPlayerGroupIE
, BBCCoUkPlaylistIE
)
820 return (False if any(ie
.suitable(url
) for ie
in EXCLUDE_IE
)
821 else super(BBCIE
, cls
).suitable(url
))
823 def _extract_from_media_meta(self
, media_meta
, video_id
):
824 # Direct links to media in media metadata (e.g.
825 # http://www.bbc.com/turkce/haberler/2015/06/150615_telabyad_kentin_cogu)
826 # TODO: there are also f4m and m3u8 streams incorporated in playlist.sxml
827 source_files
= media_meta
.get('sourceFiles')
831 'format_id': format_id
,
832 'ext': f
.get('encoding'),
833 'tbr': float_or_none(f
.get('bitrate'), 1000),
834 'filesize': int_or_none(f
.get('filesize')),
835 } for format_id
, f
in source_files
.items() if f
.get('url')], []
837 programme_id
= media_meta
.get('externalId')
839 return self
._download
_media
_selector
(programme_id
)
841 # Process playlist.sxml as legacy playlist
842 href
= media_meta
.get('href')
844 playlist
= self
._download
_legacy
_playlist
_url
(href
)
845 _
, _
, _
, _
, formats
, subtitles
= self
._extract
_from
_legacy
_playlist
(playlist
, video_id
)
846 return formats
, subtitles
850 def _extract_from_playlist_sxml(self
, url
, playlist_id
, timestamp
):
851 programme_id
, title
, description
, duration
, formats
, subtitles
= \
852 self
._process
_legacy
_playlist
_url
(url
, playlist_id
)
853 self
._sort
_formats
(formats
)
857 'description': description
,
858 'duration': duration
,
859 'timestamp': timestamp
,
861 'subtitles': subtitles
,
864 def _real_extract(self
, url
):
865 playlist_id
= self
._match
_id
(url
)
867 webpage
= self
._download
_webpage
(url
, playlist_id
)
869 json_ld_info
= self
._search
_json
_ld
(webpage
, playlist_id
, default
={})
870 timestamp
= json_ld_info
.get('timestamp')
872 playlist_title
= json_ld_info
.get('title')
873 if not playlist_title
:
874 playlist_title
= self
._og
_search
_title
(
875 webpage
, default
=None) or self
._html
_search
_regex
(
876 r
'<title>(.+?)</title>', webpage
, 'playlist title', default
=None)
878 playlist_title
= re
.sub(r
'(.+)\s*-\s*BBC.*?$', r
'\1', playlist_title
).strip()
880 playlist_description
= json_ld_info
.get(
881 'description') or self
._og
_search
_description
(webpage
, default
=None)
884 timestamp
= parse_iso8601(self
._search
_regex
(
885 [r
'<meta[^>]+property="article:published_time"[^>]+content="([^"]+)"',
886 r
'itemprop="datePublished"[^>]+datetime="([^"]+)"',
887 r
'"datePublished":\s*"([^"]+)'],
888 webpage
, 'date', default
=None))
892 # article with multiple videos embedded with playlist.sxml (e.g.
893 # http://www.bbc.com/sport/0/football/34475836)
894 playlists
= re
.findall(r
'<param[^>]+name="playlist"[^>]+value="([^"]+)"', webpage
)
895 playlists
.extend(re
.findall(r
'data-media-id="([^"]+/playlist\.sxml)"', webpage
))
898 self
._extract
_from
_playlist
_sxml
(playlist_url
, playlist_id
, timestamp
)
899 for playlist_url
in playlists
]
901 # news article with multiple videos embedded with data-playable
902 data_playables
= re
.findall(r
'data-playable=(["\'])({.+?}
)\
1', webpage)
904 for _, data_playable_json in data_playables:
905 data_playable = self._parse_json(
906 unescapeHTML(data_playable_json), playlist_id, fatal=False)
907 if not data_playable:
909 settings = data_playable.get('settings
', {})
911 # data-playable with video vpid in settings.playlistObject.items (e.g.
912 # http://www.bbc.com/news/world-us-canada-34473351)
913 playlist_object = settings.get('playlistObject
', {})
915 items = playlist_object.get('items
')
916 if items and isinstance(items, list):
917 title = playlist_object['title
']
918 description = playlist_object.get('summary
')
919 duration = int_or_none(items[0].get('duration
'))
920 programme_id = items[0].get('vpid
')
921 formats, subtitles = self._download_media_selector(programme_id)
922 self._sort_formats(formats)
926 'description
': description,
927 'timestamp
': timestamp,
928 'duration
': duration,
930 'subtitles
': subtitles,
933 # data-playable without vpid but with a playlist.sxml URLs
934 # in otherSettings.playlist (e.g.
935 # http://www.bbc.com/turkce/multimedya/2015/10/151010_vid_ankara_patlama_ani)
936 playlist = data_playable.get('otherSettings
', {}).get('playlist', {})
939 for key in ('streaming
', 'progressiveDownload
'):
940 playlist_url = playlist.get('%sUrl
' % key)
944 info = self._extract_from_playlist_sxml(
945 playlist_url, playlist_id, timestamp)
949 entry['title
'] = info['title
']
950 entry['formats
'].extend(info['formats
'])
951 except ExtractorError as e:
952 # Some playlist URL may fail with 500, at the same time
953 # the other one may work fine (e.g.
954 # http://www.bbc.com/turkce/haberler/2015/06/150615_telabyad_kentin_cogu)
955 if isinstance(e.cause, compat_HTTPError) and e.cause.code == 500:
959 self._sort_formats(entry['formats
'])
960 entries.append(entry)
963 return self.playlist_result(entries, playlist_id, playlist_title, playlist_description)
965 # http://www.bbc.co.uk/learningenglish/chinese/features/lingohack/ep-181227
966 group_id = self._search_regex(
967 r'<div
[^
>]+\bclass
=["\']video["\'][^
>]+\bdata
-pid
=["\'](%s)' % self._ID_REGEX,
968 webpage, 'group id', default=None)
970 return self.url_result(
971 'https://www.bbc.co.uk/programmes/%s' % group_id,
972 ie=BBCCoUkIE.ie_key())
974 # single video story (e.g. http://www.bbc.com/travel/story/20150625-sri-lankas-spicy-secret)
975 programme_id = self._search_regex(
976 [r'data-(?:video-player|media)-vpid="(%s)"' % self._ID_REGEX,
977 r'<param[^>]+name="externalIdentifier
"[^>]+value="(%s)"' % self._ID_REGEX,
978 r'videoId\s*:\s*["\'](%s)["\']' % self._ID_REGEX],
979 webpage, 'vpid', default=None)
982 formats, subtitles = self._download_media_selector(programme_id)
983 self._sort_formats(formats)
984 # digitalData may be missing (e.g. http://www.bbc.com/autos/story/20130513-hyundais-rock-star)
985 digital_data = self._parse_json(
987 r'var\s+digitalData\s*=\s*({.+?});?\n', webpage, 'digital data', default='{}'),
988 programme_id, fatal=False)
989 page_info = digital_data.get('page', {}).get('pageInfo', {})
990 title = page_info.get('pageName') or self._og_search_title(webpage)
991 description = page_info.get('description') or self._og_search_description(webpage)
992 timestamp = parse_iso8601(page_info.get('publicationDate')) or timestamp
996 'description': description,
997 'timestamp': timestamp,
999 'subtitles': subtitles,
1002 # bbc reel (e.g. https://www.bbc.com/reel/video/p07c6sb6/how-positive-thinking-is-harming-your-happiness)
1003 initial_data = self._parse_json(self._html_search_regex(
1004 r'<script[^>]+id=(["\'])initial
-data\
1[^
>]+data
-json
=(["\'])(?P<json>(?:(?!\2).)+)',
1005 webpage, 'initial data', default='{}', group='json'), playlist_id, fatal=False)
1007 init_data = try_get(
1008 initial_data, lambda x: x['initData']['items'][0], dict) or {}
1009 smp_data = init_data.get('smpData') or {}
1010 clip_data = try_get(smp_data, lambda x: x['items'][0], dict) or {}
1011 version_id = clip_data.get('versionID')
1013 title = smp_data['title']
1014 formats, subtitles = self._download_media_selector(version_id)
1015 self._sort_formats(formats)
1016 image_url = smp_data.get('holdingImageURL')
1017 display_date = init_data.get('displayDate')
1018 topic_title = init_data.get('topicTitle')
1024 'alt_title': init_data.get('shortTitle'),
1025 'thumbnail': image_url.replace('$recipe', 'raw') if image_url else None,
1026 'description': smp_data.get('summary') or init_data.get('shortSummary'),
1027 'upload_date': display_date.replace('-', '') if display_date else None,
1028 'subtitles': subtitles,
1029 'duration': int_or_none(clip_data.get('duration')),
1030 'categories': [topic_title] if topic_title else None,
1033 # Morph based embed (e.g. http://www.bbc.co.uk/sport/live/olympics/36895975)
1034 # There are several setPayload calls may be present but the video
1035 # seems to be always related to the first one
1036 morph_payload = self._parse_json(
1038 r'Morph\.setPayload\([^,]+,\s*({.+?})\);',
1039 webpage, 'morph payload', default='{}'),
1040 playlist_id, fatal=False)
1042 components = try_get(morph_payload, lambda x: x['body']['components'], list) or []
1043 for component in components:
1044 if not isinstance(component, dict):
1046 lead_media = try_get(component, lambda x: x['props']['leadMedia'], dict)
1049 identifiers = lead_media.get('identifiers')
1050 if not identifiers or not isinstance(identifiers, dict):
1052 programme_id = identifiers.get('vpid') or identifiers.get('playablePid')
1053 if not programme_id:
1055 title = lead_media.get('title') or self._og_search_title(webpage)
1056 formats, subtitles = self._download_media_selector(programme_id)
1057 self._sort_formats(formats)
1058 description = lead_media.get('summary')
1059 uploader = lead_media.get('masterBrand')
1060 uploader_id = lead_media.get('mid')
1062 duration_d = lead_media.get('duration')
1063 if isinstance(duration_d, dict):
1064 duration = parse_duration(dict_get(
1065 duration_d, ('rawDuration', 'formattedDuration', 'spokenDuration')))
1069 'description': description,
1070 'duration': duration,
1071 'uploader': uploader,
1072 'uploader_id': uploader_id,
1074 'subtitles': subtitles,
1077 preload_state = self._parse_json(self._search_regex(
1078 r'window\.__PRELOADED_STATE__\s*=\s*({.+?});', webpage,
1079 'preload state', default='{}'), playlist_id, fatal=False)
1081 current_programme = preload_state.get('programmes', {}).get('current') or {}
1082 programme_id = current_programme.get('id')
1083 if current_programme and programme_id and current_programme.get('type') == 'playable_item':
1084 title = current_programme.get('titles', {}).get('tertiary') or playlist_title
1085 formats, subtitles = self._download_media_selector(programme_id)
1086 self._sort_formats(formats)
1087 synopses = current_programme.get('synopses') or {}
1088 network = current_programme.get('network') or {}
1089 duration = int_or_none(
1090 current_programme.get('duration', {}).get('value'))
1092 image_url = current_programme.get('image_url')
1094 thumbnail = image_url.replace('{recipe}', 'raw')
1098 'description': dict_get(synopses, ('long', 'medium', 'short')),
1099 'thumbnail': thumbnail,
1100 'duration': duration,
1101 'uploader': network.get('short_title'),
1102 'uploader_id': network.get('id'),
1104 'subtitles': subtitles,
1107 bbc3_config = self._parse_json(
1109 r'(?s)bbcthreeConfig\s*=\s*({.+?})\s*;\s*<', webpage,
1110 'bbcthree config', default='{}'),
1111 playlist_id, transform_source=js_to_json, fatal=False) or {}
1112 payload = bbc3_config.get('payload') or {}
1114 clip = payload.get('currentClip') or {}
1115 clip_vpid = clip.get('vpid')
1116 clip_title = clip.get('title')
1117 if clip_vpid and clip_title:
1118 formats, subtitles = self._download_media_selector(clip_vpid)
1119 self._sort_formats(formats)
1122 'title': clip_title,
1123 'thumbnail': dict_get(clip, ('poster', 'imageUrl')),
1124 'description': clip.get('description'),
1125 'duration': parse_duration(clip.get('duration')),
1127 'subtitles': subtitles,
1129 bbc3_playlist = try_get(
1130 payload, lambda x: x['content']['bbcMedia']['playlist'],
1133 playlist_title = bbc3_playlist.get('title') or playlist_title
1134 thumbnail = bbc3_playlist.get('holdingImageURL')
1136 for bbc3_item in bbc3_playlist['items']:
1137 programme_id = bbc3_item.get('versionID')
1138 if not programme_id:
1140 formats, subtitles = self._download_media_selector(programme_id)
1141 self._sort_formats(formats)
1144 'title': playlist_title,
1145 'thumbnail': thumbnail,
1146 'timestamp': timestamp,
1148 'subtitles': subtitles,
1150 return self.playlist_result(
1151 entries, playlist_id, playlist_title, playlist_description)
1153 initial_data = self._parse_json(self._search_regex(
1154 r'window\.__INITIAL_DATA__\s*=\s*({.+?});', webpage,
1155 'preload state', default='{}'), playlist_id, fatal=False)
1157 def parse_media(media):
1160 for item in (try_get(media, lambda x: x['media']['items'], list) or []):
1161 item_id = item.get('id')
1162 item_title = item.get('title')
1163 if not (item_id and item_title):
1165 formats, subtitles = self._download_media_selector(item_id)
1166 self._sort_formats(formats)
1169 'title': item_title,
1170 'thumbnail': item.get('holdingImageUrl'),
1172 'subtitles': subtitles,
1174 for resp in (initial_data.get('data') or {}).values():
1175 name = resp.get('name')
1176 if name == 'media-experience':
1177 parse_media(try_get(resp, lambda x: x['data']['initialItem']['mediaItem'], dict))
1178 elif name == 'article':
1179 for block in (try_get(resp, lambda x: x['data']['blocks'], list) or []):
1180 if block.get('type') != 'media':
1182 parse_media(block.get('model'))
1183 return self.playlist_result(
1184 entries, playlist_id, playlist_title, playlist_description)
1186 def extract_all(pattern):
1187 return list(filter(None, map(
1188 lambda s: self._parse_json(s, playlist_id, fatal=False),
1189 re.findall(pattern, webpage))))
1191 # Multiple video article (e.g.
1192 # http://www.bbc.co.uk/blogs/adamcurtis/entries/3662a707-0af9-3149-963f-47bea720b460)
1193 EMBED_URL = r'https?://(?:www\.)?bbc\.co\.uk/(?:[^/]+/)+%s(?:\b[^"]+)?
' % self._ID_REGEX
1195 for match in extract_all(r'new\s
+SMP\
(({.+?}
)\
)'):
1196 embed_url = match.get('playerSettings
', {}).get('externalEmbedUrl
')
1197 if embed_url and re.match(EMBED_URL, embed_url):
1198 entries.append(embed_url)
1199 entries.extend(re.findall(
1200 r'setPlaylist\
("(%s)"\
)' % EMBED_URL, webpage))
1202 return self.playlist_result(
1203 [self.url_result(entry_, 'BBCCoUk
') for entry_ in entries],
1204 playlist_id, playlist_title, playlist_description)
1206 # Multiple video article (e.g. http://www.bbc.com/news/world-europe-32668511)
1207 medias = extract_all(r"data-media-meta='({[^']+}
)'")
1210 # Single video article (e.g. http://www.bbc.com/news/video_and_audio/international)
1211 media_asset = self._search_regex(
1212 r'mediaAssetPage\
.init\
(\s
*({.+?}
), "/',
1213 webpage, 'media asset', default=None)
1215 media_asset_page = self._parse_json(media_asset, playlist_id, fatal=False)
1217 for video in media_asset_page.get('videos', {}).values():
1218 medias.extend(video.values())
1221 # Multiple video playlist with single `now playing` entry (e.g.
1222 # http://www.bbc.com/news/video_and_audio/must_see/33767813)
1223 vxp_playlist = self._parse_json(
1225 r'<script[^>]+class="vxp
-playlist
-data
"[^>]+type="application
/json
"[^>]*>([^<]+)</script>',
1226 webpage, 'playlist data'),
1228 playlist_medias = []
1229 for item in vxp_playlist:
1230 media = item.get('media')
1233 playlist_medias.append(media)
1234 # Download single video if found media with asset id matching the video id from URL
1235 if item.get('advert', {}).get('assetId') == playlist_id:
1238 # Fallback to the whole playlist
1240 medias = playlist_medias
1243 for num, media_meta in enumerate(medias, start=1):
1244 formats, subtitles = self._extract_from_media_meta(media_meta, playlist_id)
1247 self._sort_formats(formats)
1249 video_id = media_meta.get('externalId')
1251 video_id = playlist_id if len(medias) == 1 else '%s-%s' % (playlist_id, num)
1253 title = media_meta.get('caption')
1255 title = playlist_title if len(medias) == 1 else '%s - Video %s' % (playlist_title, num)
1257 duration = int_or_none(media_meta.get('durationInSeconds')) or parse_duration(media_meta.get('duration'))
1260 for image in media_meta.get('images', {}).values():
1261 images.extend(image.values())
1262 if 'image' in media_meta:
1263 images.append(media_meta['image'])
1266 'url': image.get('href'),
1267 'width': int_or_none(image.get('width')),
1268 'height': int_or_none(image.get('height')),
1269 } for image in images]
1274 'thumbnails': thumbnails,
1275 'duration': duration,
1276 'timestamp': timestamp,
1278 'subtitles': subtitles,
1281 return self.playlist_result(entries, playlist_id, playlist_title, playlist_description)
1284 class BBCCoUkArticleIE(InfoExtractor):
1285 _VALID_URL = r'https?://(?:www\.)?bbc\.co\.uk/programmes/articles/(?P<id>[a-zA-Z0-9]+)'
1286 IE_NAME = 'bbc.co.uk:article'
1287 IE_DESC = 'BBC articles'
1290 'url': 'http://www.bbc.co.uk/programmes/articles/3jNQLTMrPlYGTBn0WV6M2MS/not-your-typical-role-model-ada-lovelace-the-19th-century-programmer',
1292 'id': '3jNQLTMrPlYGTBn0WV6M2MS',
1293 'title': 'Calculating Ada: The Countess of Computing - Not your typical role model: Ada Lovelace the 19th century programmer - BBC Four',
1294 'description': 'Hannah Fry reveals some of her surprising discoveries about Ada Lovelace during filming.',
1296 'playlist_count': 4,
1297 'add_ie': ['BBCCoUk'],
1300 def _real_extract(self, url):
1301 playlist_id = self._match_id(url)
1303 webpage = self._download_webpage(url, playlist_id)
1305 title = self._og_search_title(webpage)
1306 description = self._og_search_description(webpage).strip()
1308 entries = [self.url_result(programme_url) for programme_url in re.findall(
1309 r'<div[^>]+typeof="Clip
"[^>]+resource="([^
"]+)"', webpage)]
1311 return self.playlist_result(entries, playlist_id, title, description)
1314 class BBCCoUkPlaylistBaseIE(InfoExtractor):
1315 def _entries(self, webpage, url, playlist_id):
1316 single_page = 'page
' in compat_urlparse.parse_qs(
1317 compat_urlparse.urlparse(url).query)
1318 for page_num in itertools.count(2):
1319 for video_id in re.findall(
1320 self._VIDEO_ID_TEMPLATE % BBCCoUkIE._ID_REGEX, webpage):
1321 yield self.url_result(
1322 self._URL_TEMPLATE % video_id, BBCCoUkIE.ie_key())
1325 next_page = self._search_regex(
1326 r'<li
[^
>]+class=(["\'])pagination_+next\1[^>]*><a[^>]+href=(["\'])(?P
<url
>(?
:(?
!\
2).)+)\
2',
1327 webpage, 'next page url
', default=None, group='url
')
1330 webpage = self._download_webpage(
1331 compat_urlparse.urljoin(url, next_page), playlist_id,
1332 'Downloading page
%d' % page_num, page_num)
1334 def _real_extract(self, url):
1335 playlist_id = self._match_id(url)
1337 webpage = self._download_webpage(url, playlist_id)
1339 title, description = self._extract_title_and_description(webpage)
1341 return self.playlist_result(
1342 self._entries(webpage, url, playlist_id),
1343 playlist_id, title, description)
1346 class BBCCoUkIPlayerPlaylistBaseIE(InfoExtractor):
1347 _VALID_URL_TMPL = r'https?
://(?
:www\
.)?bbc\
.co\
.uk
/iplayer
/%%s/(?P
<id>%s)' % BBCCoUkIE._ID_REGEX
1350 def _get_default(episode, key, default_key='default
'):
1351 return try_get(episode, lambda x: x[key][default_key])
1353 def _get_description(self, data):
1354 synopsis = data.get(self._DESCRIPTION_KEY) or {}
1355 return dict_get(synopsis, ('large
', 'medium
', 'small
'))
1357 def _fetch_page(self, programme_id, per_page, series_id, page):
1358 elements = self._get_elements(self._call_api(
1359 programme_id, per_page, page + 1, series_id))
1360 for element in elements:
1361 episode = self._get_episode(element)
1362 episode_id = episode.get('id')
1366 image = self._get_episode_image(episode)
1368 thumbnail = image.replace('{recipe}
', 'raw
')
1369 category = self._get_default(episode, 'labels
', 'category
')
1373 'title
': self._get_episode_field(episode, 'subtitle
'),
1374 'url
': 'https
://www
.bbc
.co
.uk
/iplayer
/episode
/' + episode_id,
1375 'thumbnail
': thumbnail,
1376 'description
': self._get_description(episode),
1377 'categories
': [category] if category else None,
1378 'series
': self._get_episode_field(episode, 'title
'),
1379 'ie_key
': BBCCoUkIE.ie_key(),
1382 def _real_extract(self, url):
1383 pid = self._match_id(url)
1384 qs = compat_parse_qs(compat_urllib_parse_urlparse(url).query)
1385 series_id = qs.get('seriesId
', [None])[0]
1386 page = qs.get('page
', [None])[0]
1387 per_page = 36 if page else self._PAGE_SIZE
1388 fetch_page = functools.partial(self._fetch_page, pid, per_page, series_id)
1389 entries = fetch_page(int(page) - 1) if page else OnDemandPagedList(fetch_page, self._PAGE_SIZE)
1390 playlist_data = self._get_playlist_data(self._call_api(pid, 1))
1391 return self.playlist_result(
1392 entries, pid, self._get_playlist_title(playlist_data),
1393 self._get_description(playlist_data))
1396 class BBCCoUkIPlayerEpisodesIE(BBCCoUkIPlayerPlaylistBaseIE):
1397 IE_NAME = 'bbc
.co
.uk
:iplayer
:episodes
'
1398 _VALID_URL = BBCCoUkIPlayerPlaylistBaseIE._VALID_URL_TMPL % 'episodes
'
1400 'url
': 'http
://www
.bbc
.co
.uk
/iplayer
/episodes
/b05rcz9v
',
1403 'title
': 'The Disappearance
',
1404 'description
': 'md5
:58eb101aee3116bad4da05f91179c0cb
',
1406 'playlist_mincount
': 8,
1409 'url
': 'https
://www
.bbc
.co
.uk
/iplayer
/episodes
/b094m5t9
/doctor
-foster
',
1412 'title
': 'Doctor Foster
',
1413 'description
': 'md5
:5aa9195fad900e8e14b52acd765a9fd6
',
1415 'playlist_mincount
': 10,
1418 'url
': 'https
://www
.bbc
.co
.uk
/iplayer
/episodes
/b094m5t9
/doctor
-foster?seriesId
=b094m6nv
',
1421 'title
': 'Doctor Foster
',
1422 'description
': 'md5
:5aa9195fad900e8e14b52acd765a9fd6
',
1424 'playlist_mincount
': 5,
1427 'url
': 'https
://www
.bbc
.co
.uk
/iplayer
/episodes
/m0004c4v
/beechgrove
',
1430 'title
': 'Beechgrove
',
1431 'description
': 'Gardening show that celebrates Scottish horticulture
and growing conditions
.',
1433 'playlist_mincount
': 37,
1436 'url
': 'https
://www
.bbc
.co
.uk
/iplayer
/episodes
/m0004c4v
/beechgrove?page
=2',
1439 'title
': 'Beechgrove
',
1440 'description
': 'Gardening show that celebrates Scottish horticulture
and growing conditions
.',
1442 'playlist_mincount
': 1,
1445 _DESCRIPTION_KEY = 'synopsis
'
1447 def _get_episode_image(self, episode):
1448 return self._get_default(episode, 'image
')
1450 def _get_episode_field(self, episode, field):
1451 return self._get_default(episode, field)
1454 def _get_elements(data):
1455 return data['entities
']['results
']
1458 def _get_episode(element):
1459 return element.get('episode
') or {}
1461 def _call_api(self, pid, per_page, page=1, series_id=None):
1465 'perPage
': per_page,
1468 variables['sliceId
'] = series_id
1469 return self._download_json(
1470 'https
://graph
.ibl
.api
.bbc
.co
.uk
/', pid, headers={
1471 'Content
-Type
': 'application
/json
'
1472 }, data=json.dumps({
1473 'id': '5692d93d5aac8d796a0305e895e61551
',
1474 'variables
': variables,
1475 }).encode('utf
-8'))['data
']['programme
']
1478 def _get_playlist_data(data):
1481 def _get_playlist_title(self, data):
1482 return self._get_default(data, 'title
')
1485 class BBCCoUkIPlayerGroupIE(BBCCoUkIPlayerPlaylistBaseIE):
1486 IE_NAME = 'bbc
.co
.uk
:iplayer
:group
'
1487 _VALID_URL = BBCCoUkIPlayerPlaylistBaseIE._VALID_URL_TMPL % 'group
'
1489 # Available for over a year unlike 30 days for most other programmes
1490 'url
': 'http
://www
.bbc
.co
.uk
/iplayer
/group
/p02tcc32
',
1493 'title
': 'Bohemian Icons
',
1494 'description
': 'md5
:683e901041b2fe9ba596f2ab04c4dbe7
',
1496 'playlist_mincount
': 10,
1499 'url
': 'https
://www
.bbc
.co
.uk
/iplayer
/group
/p081d7j7
',
1502 'title
': 'Music
in Scotland
',
1503 'description
': 'Perfomances
in Scotland
and programmes featuring Scottish acts
.',
1505 'playlist_mincount
': 47,
1508 'url
': 'https
://www
.bbc
.co
.uk
/iplayer
/group
/p081d7j7?page
=2',
1511 'title
': 'Music
in Scotland
',
1512 'description
': 'Perfomances
in Scotland
and programmes featuring Scottish acts
.',
1514 'playlist_mincount
': 11,
1517 _DESCRIPTION_KEY = 'synopses
'
1519 def _get_episode_image(self, episode):
1520 return self._get_default(episode, 'images
', 'standard
')
1522 def _get_episode_field(self, episode, field):
1523 return episode.get(field)
1526 def _get_elements(data):
1527 return data['elements
']
1530 def _get_episode(element):
1533 def _call_api(self, pid, per_page, page=1, series_id=None):
1534 return self._download_json(
1535 'http
://ibl
.api
.bbc
.co
.uk
/ibl
/v1
/groups
/%s/episodes
' % pid,
1538 'per_page
': per_page,
1539 })['group_episodes
']
1542 def _get_playlist_data(data):
1543 return data['group
']
1545 def _get_playlist_title(self, data):
1546 return data.get('title
')
1549 class BBCCoUkPlaylistIE(BBCCoUkPlaylistBaseIE):
1550 IE_NAME = 'bbc
.co
.uk
:playlist
'
1551 _VALID_URL = r'https?
://(?
:www\
.)?bbc\
.co\
.uk
/programmes
/(?P
<id>%s)/(?
:episodes|broadcasts|clips
)' % BBCCoUkIE._ID_REGEX
1552 _URL_TEMPLATE = 'http
://www
.bbc
.co
.uk
/programmes
/%s'
1553 _VIDEO_ID_TEMPLATE = r'data
-pid
=["\'](%s)'
1555 'url': 'http://www.bbc.co.uk/programmes/b05rcz9v/clips',
1558 'title': 'The Disappearance - Clips - BBC Four',
1559 'description': 'French thriller serial about a missing teenager.',
1561 'playlist_mincount': 7,
1563 # multipage playlist, explicit page
1564 'url': 'http://www.bbc.co.uk/programmes/b00mfl7n/clips?page=1',
1567 'title': 'Frozen Planet - Clips - BBC One',
1568 'description': 'md5:65dcbf591ae628dafe32aa6c4a4a0d8c',
1570 'playlist_mincount': 24,
1572 # multipage playlist, all pages
1573 'url': 'http://www.bbc.co.uk/programmes/b00mfl7n/clips',
1576 'title': 'Frozen Planet - Clips - BBC One',
1577 'description': 'md5:65dcbf591ae628dafe32aa6c4a4a0d8c',
1579 'playlist_mincount': 142,
1581 'url': 'http://www.bbc.co.uk/programmes/b05rcz9v/broadcasts/2016/06',
1582 'only_matching': True,
1584 'url': 'http://www.bbc.co.uk/programmes/b05rcz9v/clips',
1585 'only_matching': True,
1587 'url': 'http://www.bbc.co.uk/programmes/b055jkys/episodes/player',
1588 'only_matching': True,
1591 def _extract_title_and_description(self, webpage):
1592 title = self._og_search_title(webpage, fatal=False)
1593 description = self._og_search_description(webpage)
1594 return title, description