]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tv5mondeplus.py
88b6baa316b54eb58e3deb5d69f2fd04c1795bba
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  16 class TV5MondePlusIE(InfoExtractor
): 
  18     _VALID_URL 
= r
'https?://(?:www\.)?tv5mondeplus\.com/toutes-les-videos/[^/]+/(?P<id>[^/?#]+)' 
  20         'url': 'http://www.tv5mondeplus.com/toutes-les-videos/documentaire/tdah-mon-amour-tele-quebec-tdah-mon-amour-ep001-enfants', 
  21         'md5': '12130fc199f020673138a83466542ec6', 
  23             'id': 'tdah-mon-amour-tele-quebec-tdah-mon-amour-ep001-enfants', 
  25             'title': 'Tdah, mon amour - Enfants', 
  26             'description': 'md5:230e3aca23115afcf8006d1bece6df74', 
  27             'upload_date': '20170401', 
  28             'timestamp': 1491022860, 
  33     def _real_extract(self
, url
): 
  34         display_id 
= self
._match
_id
(url
) 
  35         webpage 
= self
._download
_webpage
(url
, display_id
) 
  37         if ">Ce programme n'est malheureusement pas disponible pour votre zone géographique.<" in webpage
: 
  38             self
.raise_geo_restricted(countries
=['FR']) 
  40         series 
= get_element_by_class('video-detail__title', webpage
) 
  41         title 
= episode 
= get_element_by_class( 
  42             'video-detail__subtitle', webpage
) or series
 
  43         if series 
and series 
!= title
: 
  44             title 
= '%s - %s' % (series
, title
) 
  45         vpl_data 
= extract_attributes(self
._search
_regex
( 
  46             r
'(<[^>]+class="video_player_loader"[^>]+>)', 
  47             webpage
, 'video player loader')) 
  49         video_files 
= self
._parse
_json
( 
  50             vpl_data
['data-broadcast'], display_id
).get('files', []) 
  52         for video_file 
in video_files
: 
  53             v_url 
= video_file
.get('url') 
  56             video_format 
= video_file
.get('format') or determine_ext(v_url
) 
  57             if video_format 
== 'm3u8': 
  58                 formats
.extend(self
._extract
_m
3u8_formats
( 
  59                     v_url
, display_id
, 'mp4', 'm3u8_native', 
  60                     m3u8_id
='hls', fatal
=False)) 
  64                     'format_id': video_format
, 
  66         self
._sort
_formats
(formats
) 
  70             'display_id': display_id
, 
  72             'description': clean_html(get_element_by_class('video-detail__description', webpage
)), 
  73             'thumbnail': vpl_data
.get('data-image'), 
  74             'duration': int_or_none(vpl_data
.get('data-duration')) or parse_duration(self
._html
_search
_meta
('duration', webpage
)), 
  75             'timestamp': parse_iso8601(self
._html
_search
_meta
('uploadDate', webpage
)),