]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/radiocanada.py
4f05bbddc6d35fc8ec709fcb005638abcbe77779
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
18 class RadioCanadaIE(InfoExtractor
):
19 IE_NAME
= 'radiocanada'
20 _VALID_URL
= r
'(?:radiocanada:|https?://ici\.radio-canada\.ca/widgets/mediaconsole/)(?P<app_code>[^:/]+)[:/](?P<id>[0-9]+)'
22 'url': 'http://ici.radio-canada.ca/widgets/mediaconsole/medianet/7184272',
26 'title': 'Le parcours du tireur capté sur vidéo',
27 'description': 'Images des caméras de surveillance fournies par la GRC montrant le parcours du tireur d\'Ottawa',
28 'upload_date': '20141023',
32 'skip_download': True,
36 def _real_extract(self
, url
):
37 app_code
, video_id
= re
.match(self
._VALID
_URL
, url
).groups()
40 # TODO: extract m3u8 and f4m formats
41 # m3u8 formats can be extracted using ipad device_type return 403 error code when ffmpeg try to download segements
42 # f4m formats can be extracted using flashhd device_type but they produce unplayable file
43 for device_type
in ('flash',):
44 v_data
= self
._download
_xml
(
45 'http://api.radio-canada.ca/validationMedia/v1/Validation.ashx',
46 video_id
, note
='Downloading %s XML' % device_type
, query
={
49 'connectionType': 'broadband',
50 'multibitrate': 'true',
51 'deviceType': device_type
,
52 # paysJ391wsHjbOJwvCs26toz and bypasslock are used to bypass geo-restriction
53 'paysJ391wsHjbOJwvCs26toz': 'CA',
54 'bypasslock': 'NZt5K62gRqfc',
56 v_url
= xpath_text(v_data
, 'url')
60 raise ExtractorError('%s said: %s' % (
61 self
.IE_NAME
, xpath_text(v_data
, 'message')), expected
=True)
62 ext
= determine_ext(v_url
)
64 formats
.extend(self
._extract
_m
3u8_formats
(
65 v_url
, video_id
, 'mp4', m3u8_id
='hls', fatal
=False))
67 formats
.extend(self
._extract
_f
4m
_formats
(v_url
, video_id
, f4m_id
='hds', fatal
=False))
69 ext
= determine_ext(v_url
)
70 bitrates
= xpath_element(v_data
, 'bitrates')
71 for url_e
in bitrates
.findall('url'):
72 tbr
= int_or_none(url_e
.get('bitrate'))
76 'format_id': 'rtmp-%d' % tbr
,
77 'url': re
.sub(r
'\d+\.%s' % ext
, '%d.%s' % (tbr
, ext
), v_url
),
80 'width': int_or_none(url_e
.get('width')),
81 'height': int_or_none(url_e
.get('height')),
84 self
._sort
_formats
(formats
)
86 metadata
= self
._download
_xml
(
87 'http://api.radio-canada.ca/metaMedia/v1/index.ashx',
88 video_id
, note
='Downloading metadata XML', query
={
94 el
= find_xpath_attr(metadata
, './/Meta', 'name', name
)
95 return el
.text
if el
is not None else None
99 'title': get_meta('Title'),
100 'description': get_meta('Description') or get_meta('ShortDescription'),
101 'thumbnail': get_meta('imageHR') or get_meta('imageMR') or get_meta('imageBR'),
102 'duration': int_or_none(get_meta('length')),
103 'series': get_meta('Emission'),
104 'season_number': int_or_none('SrcSaison'),
105 'episode_number': int_or_none('SrcEpisode'),
106 'upload_date': unified_strdate(get_meta('Date')),
111 class RadioCanadaAudioVideoIE(InfoExtractor
):
112 'radiocanada:audiovideo'
113 _VALID_URL
= r
'https?://ici\.radio-canada\.ca/audio-video/media-(?P<id>[0-9]+)'
115 'url': 'http://ici.radio-canada.ca/audio-video/media-7527184/barack-obama-au-vietnam',
119 'title': 'Barack Obama au Vietnam',
120 'description': 'Les États-Unis lèvent l\'embargo sur la vente d\'armes qui datait de la guerre du Vietnam',
121 'upload_date': '20160523',
125 'skip_download': True,
129 def _real_extract(self
, url
):
130 return self
.url_result('radiocanada:medianet:%s' % self
._match
_id
(url
))