2 from __future__ import unicode_literals
4 from .common import InfoExtractor
11 class RTBFIE(InfoExtractor):
13 https?://www\.rtbf\.be/
16 ouftivi/heros/[^&]+&videoId=
22 'url': 'https://www.rtbf.be/video/detail_les-diables-au-coeur-episode-2?id=1921274',
23 'md5': '799f334ddf2c0a582ba80c44655be570',
27 'title': 'Les Diables au coeur (épisode 2)',
32 'url': 'http://www.rtbf.be/ouftivi/heros/detail_scooby-doo-mysteres-associes?id=1097&videoId=2057442',
33 'md5': '25aea17e949e1e0c7c41270d60d25f22',
37 'title': 'Scooby-Doo, myst\xe8res associ\xe9s',
50 def _real_extract(self, url):
51 video_id = self._match_id(url)
53 webpage = self._download_webpage(
54 'http://www.rtbf.be/video/embed?id=%s' % video_id, video_id)
56 data = self._parse_json(
57 unescapeHTML(self._search_regex(
58 r'data-media="([^"]+)"', webpage, 'data video')),
61 if data.get('provider').lower() == 'youtube':
62 video_url = data.get('downloadUrl') or data.get('url')
63 return self.url_result(video_url, 'Youtube')
65 for key, format_id in self._QUALITIES:
66 format_url = data['sources'].get(key)
69 'format_id': format_id,
76 'title': data['title'],
77 'description': data.get('description') or data.get('subtitle'),
78 'thumbnail': data.get('thumbnail'),
79 'duration': data.get('duration') or data.get('realDuration'),
80 'timestamp': int_or_none(data.get('created')),
81 'view_count': int_or_none(data.get('viewCount')),