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.

49 lines
1.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. import json
  5. from .common import InfoExtractor
  6. class RTBFIE(InfoExtractor):
  7. _VALID_URL = r'https?://www.rtbf.be/video/[^\?]+\?id=(?P<id>\d+)'
  8. _TEST = {
  9. 'url': 'https://www.rtbf.be/video/detail_les-diables-au-coeur-episode-2?id=1921274',
  10. 'md5': '799f334ddf2c0a582ba80c44655be570',
  11. 'info_dict': {
  12. 'id': '1921274',
  13. 'ext': 'mp4',
  14. 'title': 'Les Diables au coeur (épisode 2)',
  15. 'description': 'Football - Diables Rouges',
  16. 'duration': 3099,
  17. 'timestamp': 1398456336,
  18. 'upload_date': '20140425',
  19. }
  20. }
  21. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. video_id = mobj.group('id')
  24. page = self._download_webpage('https://www.rtbf.be/video/embed?id=%s' % video_id, video_id)
  25. data = json.loads(self._html_search_regex(
  26. r'<div class="js-player-embed(?: player-embed)?" data-video="([^"]+)"', page, 'data video'))['data']
  27. video_url = data.get('downloadUrl') or data.get('url')
  28. if data['provider'].lower() == 'youtube':
  29. return self.url_result(video_url, 'Youtube')
  30. return {
  31. 'id': video_id,
  32. 'url': video_url,
  33. 'title': data['title'],
  34. 'description': data.get('description') or data.get('subtitle'),
  35. 'thumbnail': data['thumbnail']['large'],
  36. 'duration': data.get('duration') or data.get('realDuration'),
  37. 'timestamp': data['created'],
  38. 'view_count': data['viewCount'],
  39. }