]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tva.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  11 class TVAIE(InfoExtractor
): 
  12     _VALID_URL 
= r
'https?://videos\.tva\.ca/details/_(?P<id>\d+)' 
  14         'url': 'https://videos.tva.ca/details/_5596811470001', 
  16             'id': '5596811470001', 
  18             'title': 'Un extrait de l\'épisode du dimanche 8 octobre 2017 !', 
  19             'uploader_id': '5481942443001', 
  20             'upload_date': '20171003', 
  21             'timestamp': 1507064617, 
  25             'skip_download': True, 
  28     BRIGHTCOVE_URL_TEMPLATE 
= 'http://players.brightcove.net/5481942443001/default_default/index.html?videoId=%s' 
  30     def _real_extract(self
, url
): 
  31         video_id 
= self
._match
_id
(url
) 
  32         video_data 
= self
._download
_json
( 
  33             'https://videos.tva.ca/proxy/item/_' + video_id
, video_id
, headers
={ 
  34                 'Accept': 'application/json', 
  37         def get_attribute(key
): 
  38             for attribute 
in video_data
.get('attributes', []): 
  39                 if attribute
.get('key') == key
: 
  40                     return attribute
.get('value') 
  44             '_type': 'url_transparent', 
  46             'title': get_attribute('title'), 
  47             'url': smuggle_url(self
.BRIGHTCOVE_URL_TEMPLATE 
% video_id
, {'geo_countries': ['CA']}), 
  48             'description': get_attribute('description'), 
  49             'thumbnail': get_attribute('image-background') or get_attribute('image-landscape'), 
  50             'duration': float_or_none(get_attribute('video-duration'), 1000), 
  51             'ie_key': 'BrightcoveNew',