]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/rtbf.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  11 class RTBFIE(InfoExtractor
): 
  12     _VALID_URL 
= r
'https?://(?:www\.)?rtbf\.be/(?:video/[^?]+\?.*\bid=|ouftivi/(?:[^/]+/)*[^?]+\?.*\bvideoId=)(?P<id>\d+)' 
  14         'url': 'https://www.rtbf.be/video/detail_les-diables-au-coeur-episode-2?id=1921274', 
  15         'md5': '799f334ddf2c0a582ba80c44655be570', 
  19             'title': 'Les Diables au coeur (épisode 2)', 
  24         'url': 'http://www.rtbf.be/ouftivi/heros/detail_scooby-doo-mysteres-associes?id=1097&videoId=2057442', 
  25         'only_matching': True, 
  27         'url': 'http://www.rtbf.be/ouftivi/niouzz?videoId=2055858', 
  28         'only_matching': True, 
  38     def _real_extract(self
, url
): 
  39         video_id 
= self
._match
_id
(url
) 
  41         webpage 
= self
._download
_webpage
( 
  42             'http://www.rtbf.be/video/embed?id=%s' % video_id
, video_id
) 
  44         data 
= self
._parse
_json
( 
  45             unescapeHTML(self
._search
_regex
( 
  46                 r
'data-media="([^"]+)"', webpage
, 'data video')), 
  49         if data
.get('provider').lower() == 'youtube': 
  50             video_url 
= data
.get('downloadUrl') or data
.get('url') 
  51             return self
.url_result(video_url
, 'Youtube') 
  53         for key
, format_id 
in self
._QUALITIES
: 
  54             format_url 
= data
['sources'].get(key
) 
  57                     'format_id': format_id
, 
  64             'title': data
['title'], 
  65             'description': data
.get('description') or data
.get('subtitle'), 
  66             'thumbnail': data
.get('thumbnail'), 
  67             'duration': data
.get('duration') or data
.get('realDuration'), 
  68             'timestamp': int_or_none(data
.get('created')), 
  69             'view_count': int_or_none(data
.get('viewCount')),