aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/radiocanada.py
diff options
context:
space:
mode:
authorRemita Amine <remitamine@gmail.com>2016-09-16 17:36:22 +0100
committerRemita Amine <remitamine@gmail.com>2016-09-16 17:40:15 +0100
commit98b7506e96b5ac107a777d8bb8900623d832fba4 (patch)
treea1ca0ff8fccf924fd469d0c9bab6376b2c815827 /youtube_dl/extractor/radiocanada.py
parent52dc8a9b3f1af7abda6652a75b906d70809c475d (diff)
downloadyoutube-dl-98b7506e96b5ac107a777d8bb8900623d832fba4.tar.xz
[toutv] add support for authentication(closes #10669)
Diffstat (limited to 'youtube_dl/extractor/radiocanada.py')
-rw-r--r--youtube_dl/extractor/radiocanada.py55
1 files changed, 34 insertions, 21 deletions
diff --git a/youtube_dl/extractor/radiocanada.py b/youtube_dl/extractor/radiocanada.py
index 8ec402646..6751270ee 100644
--- a/youtube_dl/extractor/radiocanada.py
+++ b/youtube_dl/extractor/radiocanada.py
@@ -13,6 +13,7 @@ from ..utils import (
xpath_element,
ExtractorError,
determine_protocol,
+ unsmuggle_url,
)
@@ -35,28 +36,51 @@ class RadioCanadaIE(InfoExtractor):
}
def _real_extract(self, url):
+ url, smuggled_data = unsmuggle_url(url, {})
app_code, video_id = re.match(self._VALID_URL, url).groups()
- device_types = ['ipad', 'android']
+ metadata = self._download_xml(
+ 'http://api.radio-canada.ca/metaMedia/v1/index.ashx',
+ video_id, note='Downloading metadata XML', query={
+ 'appCode': app_code,
+ 'idMedia': video_id,
+ })
+
+ def get_meta(name):
+ el = find_xpath_attr(metadata, './/Meta', 'name', name)
+ return el.text if el is not None else None
+
+ if get_meta('protectionType'):
+ raise ExtractorError('This video is DRM protected.', expected=True)
+
+ device_types = ['ipad']
if app_code != 'toutv':
device_types.append('flash')
+ if not smuggled_data:
+ device_types.append('android')
formats = []
# TODO: extract f4m formats
# f4m formats can be extracted using flashhd device_type but they produce unplayable file
for device_type in device_types:
- v_data = self._download_xml(
- 'http://api.radio-canada.ca/validationMedia/v1/Validation.ashx',
- video_id, note='Downloading %s XML' % device_type, query={
- 'appCode': app_code,
- 'idMedia': video_id,
- 'connectionType': 'broadband',
- 'multibitrate': 'true',
- 'deviceType': device_type,
+ validation_url = 'http://api.radio-canada.ca/validationMedia/v1/Validation.ashx'
+ query = {
+ 'appCode': app_code,
+ 'idMedia': video_id,
+ 'connectionType': 'broadband',
+ 'multibitrate': 'true',
+ 'deviceType': device_type,
+ }
+ if smuggled_data:
+ validation_url = 'https://services.radio-canada.ca/media/validation/v2/'
+ query.update(smuggled_data)
+ else:
+ query.update({
# paysJ391wsHjbOJwvCs26toz and bypasslock are used to bypass geo-restriction
'paysJ391wsHjbOJwvCs26toz': 'CA',
'bypasslock': 'NZt5K62gRqfc',
- }, fatal=False)
+ })
+ v_data = self._download_xml(validation_url, video_id, note='Downloading %s XML' % device_type, query=query, fatal=False)
v_url = xpath_text(v_data, 'url')
if not v_url:
continue
@@ -101,17 +125,6 @@ class RadioCanadaIE(InfoExtractor):
f4m_id='hds', fatal=False))
self._sort_formats(formats)
- metadata = self._download_xml(
- 'http://api.radio-canada.ca/metaMedia/v1/index.ashx',
- video_id, note='Downloading metadata XML', query={
- 'appCode': app_code,
- 'idMedia': video_id,
- })
-
- def get_meta(name):
- el = find_xpath_attr(metadata, './/Meta', 'name', name)
- return el.text if el is not None else None
-
return {
'id': video_id,
'title': get_meta('Title'),