2014-04-28 20:32:13 +02:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import re
|
|
|
|
import json
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
|
2014-04-29 14:41:58 +02:00
|
|
|
|
|
|
|
class RTBFIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'https?://www.rtbf.be/video/[^\?]+\?id=(?P<id>\d+)'
|
2014-04-28 20:32:13 +02:00
|
|
|
_TEST = {
|
|
|
|
'url': 'https://www.rtbf.be/video/detail_les-diables-au-coeur-episode-2?id=1921274',
|
|
|
|
'md5': '799f334ddf2c0a582ba80c44655be570',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '1921274',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Les Diables au coeur (épisode 2)',
|
2014-04-29 14:41:58 +02:00
|
|
|
'description': 'Football - Diables Rouges',
|
2014-04-28 20:32:13 +02:00
|
|
|
'duration': 3099,
|
2014-04-29 14:41:58 +02:00
|
|
|
'timestamp': 1398456336,
|
|
|
|
'upload_date': '20140425',
|
2014-04-28 20:32:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
mobj = re.match(self._VALID_URL, url)
|
|
|
|
video_id = mobj.group('id')
|
|
|
|
|
2014-04-29 14:41:58 +02:00
|
|
|
page = self._download_webpage('https://www.rtbf.be/video/embed?id=%s' % video_id, video_id)
|
|
|
|
|
|
|
|
data = json.loads(self._html_search_regex(
|
|
|
|
r'<div class="js-player-embed" data-video="([^"]+)"', page, 'data video'))['data']
|
2014-04-28 20:32:13 +02:00
|
|
|
|
2014-04-29 14:41:58 +02:00
|
|
|
video_url = data.get('downloadUrl') or data.get('url')
|
2014-04-28 20:32:13 +02:00
|
|
|
|
2014-04-29 14:41:58 +02:00
|
|
|
if data['provider'].lower() == 'youtube':
|
|
|
|
return self.url_result(video_url, 'Youtube')
|
2014-04-28 20:32:13 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
2014-04-29 14:41:58 +02:00
|
|
|
'url': video_url,
|
|
|
|
'title': data['title'],
|
|
|
|
'description': data.get('description') or data.get('subtitle'),
|
|
|
|
'thumbnail': data['thumbnail']['large'],
|
|
|
|
'duration': data.get('duration') or data.get('realDuration'),
|
|
|
|
'timestamp': data['created'],
|
|
|
|
'view_count': data['viewCount'],
|
2014-04-28 20:32:13 +02:00
|
|
|
}
|