You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1170 lines
50 KiB

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