- list_id = self._match_id(url)
- webpage = self._download_webpage(url, list_id)
-
- list_title = self._html_search_regex(r'<title>(.*?)(?:\s*-\s*BBC [^ ]+)?</title>', webpage, 'list title')
-
- pubdate = self._html_search_regex(r'"datePublished":\s*"(\d+-\d+-\d+)', webpage, 'date', default=None)
- if pubdate:
- pubdate = pubdate.replace('-', '')
-
- ret = []
- jsent = []
-
- # works with bbc.com/news/something-something-123456 articles
- jsent = map(
- lambda m: self._parse_json(m, list_id),
- re.findall(r"data-media-meta='({[^']+})'", webpage)
- )
-
- if len(jsent) == 0:
- # http://www.bbc.com/news/video_and_audio/international
- # and single-video articles
- masset = self._html_search_regex(r'mediaAssetPage\.init\(\s*({.+?}), "/', webpage, 'mediaassets', default=None)
- if masset:
- jmasset = self._parse_json(masset, list_id)
- for key, val in jmasset.get('videos', {}).items():
- for skey, sval in val.items():
- sval['id'] = skey
- jsent.append(sval)
-
- if len(jsent) == 0:
- # stubbornly generic extractor for {json with "image":{allvideoshavethis},etc}
- # in http://www.bbc.com/news/video_and_audio/international
- # prone to breaking if entries have sourceFiles list
- jsent = map(
- lambda m: self._parse_json(m, list_id),
- re.findall(r"({[^{}]+image\":{[^}]+}[^}]+})", webpage)
- )
-
- if len(jsent) == 0:
- raise ExtractorError('No video found', expected=True)
-
- for jent in jsent:
- programme_id = jent.get('externalId')
- xml_url = jent.get('href')
-
- title = jent.get('caption', '')
- if title == '':
- title = list_title
-
- duration = parse_duration(jent.get('duration'))
- description = list_title
- if jent.get('caption', '') != '':
- description += ' - ' + jent.get('caption')
- thumbnail = None
- if jent.get('image') is not None:
- thumbnail = jent['image'].get('href')
-
- formats = []
- subtitles = []
-
- if programme_id:
- formats, subtitles = self._download_media_selector(programme_id)
- elif jent.get('sourceFiles') is not None:
- # mediaselector not used at
- # http://www.bbc.com/turkce/haberler/2015/06/150615_telabyad_kentin_cogu
- for key, val in jent['sourceFiles'].items():
- formats.append({
- 'ext': val.get('encoding'),
- 'url': val.get('url'),
- 'filesize': int(val.get('filesize')),
- 'format_id': key
- })
- elif xml_url:
- # Cheap fallback
- # http://playlists.bbc.co.uk/news/(list_id)[ABC..]/playlist.sxml
- xml = self._download_webpage(xml_url, programme_id, 'Downloading playlist.sxml for externalId (fallback)')
- programme_id = self._search_regex(r'<mediator [^>]*identifier="(.+?)"', xml, 'playlist.sxml (externalId fallback)')
- formats, subtitles = self._download_media_selector(programme_id)
+ playlist_id = self._match_id(url)
+
+ webpage = self._download_webpage(url, playlist_id)
+
+ timestamp = parse_iso8601(self._search_regex(
+ [r'"datePublished":\s*"([^"]+)',
+ r'<meta[^>]+property="article:published_time"[^>]+content="([^"]+)"',
+ r'itemprop="datePublished"[^>]+datetime="([^"]+)"'],
+ webpage, 'date', default=None))
+
+ # single video with playlist.sxml URL (e.g. http://www.bbc.com/sport/0/football/3365340ng)
+ playlist = self._search_regex(
+ r'<param[^>]+name="playlist"[^>]+value="([^"]+)"',
+ webpage, 'playlist', default=None)
+ if playlist:
+ programme_id, title, description, duration, formats, subtitles = \
+ self._process_legacy_playlist_url(playlist, playlist_id)
+ self._sort_formats(formats)
+ return {
+ 'id': programme_id,
+ 'title': title,
+ 'description': description,
+ 'duration': duration,
+ 'timestamp': timestamp,
+ 'formats': formats,
+ 'subtitles': subtitles,
+ }