- mobj = re.match(self._VALID_URL, url)
- video_id = mobj.group('id')
-
- # TODO more code goes here, for example ...
- webpage = self._download_webpage(url, video_id)
- title = self._html_search_regex(
- r'<meta property="og:description" content="([^"]*)"',
- webpage, 'title', mobj.group('title'))
- print title
-
- iframe_url = self._html_search_regex(r'<iframe [^>]*src="([^"]+)"',
- webpage, 'iframe')
- iframe = self._download_webpage(iframe_url, video_id)
-
- data_video_idx = iframe.find('data-video')
- next_data_idx = iframe.find('data-', data_video_idx + 1)
- json_data_start = data_video_idx + len('data-video=') + 1
- json_data_end = next_data_idx - 2
- video_data = json.loads(clean_html(iframe[json_data_start:json_data_end]))
+ video_id = self._match_id(url)
+ data = self._download_json(
+ 'http://www.rtbf.be/api/media/video?method=getVideoDetail&args[]=%s' % video_id, video_id)
+
+ error = data.get('error')
+ if error:
+ raise ExtractorError('%s said: %s' % (self.IE_NAME, error), expected=True)
+
+ data = data['data']
+
+ provider = data.get('provider')
+ if provider in self._PROVIDERS:
+ return self.url_result(data['url'], self._PROVIDERS[provider])
+
+ formats = []
+ for key, format_id in self._QUALITIES:
+ format_url = data.get(key + 'Url')
+ if format_url:
+ formats.append({
+ 'format_id': format_id,
+ 'url': format_url,
+ })
+
+ thumbnails = []
+ for thumbnail_id, thumbnail_url in data.get('thumbnail', {}).items():
+ if thumbnail_id != 'default':
+ thumbnails.append({
+ 'url': self._IMAGE_HOST + thumbnail_url,
+ 'id': thumbnail_id,
+ })