2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_urllib_parse_urlparse
19 class CanalplusIE(InfoExtractor
):
20 IE_DESC
= 'canalplus.fr, piwiplus.fr and d8.tv'
25 (?:(?:www|m)\.)?canalplus\.fr|
26 (?:www\.)?piwiplus\.fr|
31 )/(?:(?:[^/]+/)*(?P<display_id>[^/?#&]+))?(?:\?.*\bvid=(?P<vid>\d+))?|
32 player\.canalplus\.fr/#/(?P<id>\d+)
36 _VIDEO_INFO_TEMPLATE
= 'http://service.canal-plus.com/video/rest/getVideosLiees/%s/%s?format=json'
39 'piwiplus': 'teletoon',
47 'url': 'http://www.canalplus.fr/c-emissions/pid1830-c-zapping.html?vid=1192814',
50 'display_id': 'pid1830-c-zapping',
52 'title': 'Zapping - 02/07/2016',
53 'description': 'Le meilleur de toutes les chaînes, tous les jours',
54 'upload_date': '20160702',
57 'url': 'http://www.piwiplus.fr/videos-piwi/pid1405-le-labyrinthe-boing-super-ranger.html?vid=1108190',
60 'display_id': 'pid1405-le-labyrinthe-boing-super-ranger',
62 'title': 'BOING SUPER RANGER - Ep : Le labyrinthe',
63 'description': 'md5:4cea7a37153be42c1ba2c1d3064376ff',
64 'upload_date': '20140724',
66 'skip': 'Only works from France',
68 'url': 'http://www.c8.fr/c8-divertissement/ms-touche-pas-a-mon-poste/pid6318-videos-integrales.html',
69 'md5': '4b47b12b4ee43002626b97fad8fb1de5',
72 'display_id': 'pid6318-videos-integrales',
74 'title': 'TPMP ! Même le matin - Les 35H de Baba - 14/10/2016',
75 'description': 'md5:f96736c1b0ffaa96fd5b9e60ad871799',
76 'upload_date': '20161014',
78 'skip': 'Only works from France',
80 'url': 'http://www.itele.fr/chroniques/invite-michael-darmon/rachida-dati-nicolas-sarkozy-est-le-plus-en-phase-avec-les-inquietudes-des-francais-171510',
83 'display_id': 'rachida-dati-nicolas-sarkozy-est-le-plus-en-phase-avec-les-inquietudes-des-francais-171510',
85 'title': 'L\'invité de Michaël Darmon du 14/10/2016 - ',
86 'description': 'Chaque matin du lundi au vendredi, Michaël Darmon reçoit un invité politique à 8h25.',
87 'upload_date': '20161014',
90 'url': 'http://m.canalplus.fr/?vid=1398231',
91 'only_matching': True,
93 'url': 'http://www.d17.tv/emissions/pid8303-lolywood.html?vid=1397061',
94 'only_matching': True,
97 def _real_extract(self
, url
):
98 mobj
= re
.match(self
._VALID
_URL
, url
)
100 site_id
= self
._SITE
_ID
_MAP
[compat_urllib_parse_urlparse(url
).netloc
.rsplit('.', 2)[-2]]
102 # Beware, some subclasses do not define an id group
103 display_id
= remove_end(dict_get(mobj
.groupdict(), ('display_id', 'id', 'vid')), '.html')
105 webpage
= self
._download
_webpage
(url
, display_id
)
106 video_id
= self
._search
_regex
(
107 [r
'<canal:player[^>]+?videoId=(["\'])(?P
<id>\d
+)',
108 r'id=["\']canal_video_player(?P<id>\d+)'],
109 webpage, 'video id', group='id')
111 info_url = self._VIDEO_INFO_TEMPLATE % (site_id, video_id)
112 video_data = self._download_json(info_url, video_id, 'Downloading video JSON')
114 if isinstance(video_data, list):
115 video_data = [video for video in video_data if video.get('ID') == video_id][0]
116 media = video_data['MEDIA']
117 infos = video_data['INFOS']
119 preference = qualities(['MOBILE', 'BAS_DEBIT', 'HAUT_DEBIT', 'HD'])
121 fmt_url = next(iter(media.get('VIDEOS')))
122 if '/geo' in fmt_url.lower():
123 response = self._request_webpage(
124 HEADRequest(fmt_url), video_id,
125 'Checking if the video is georestricted')
126 if '/blocage' in response.geturl():
127 raise ExtractorError(
128 'The video is not available in your country',
132 for format_id, format_url in media['VIDEOS'].items():
135 if format_id == 'HLS':
136 formats.extend(self._extract_m3u8_formats(
137 format_url, video_id, 'mp4', 'm3u8_native', m3u8_id=format_id, fatal=False))
138 elif format_id == 'HDS':
139 formats.extend(self._extract_f4m_formats(
140 format_url + '?hdcore=2.11.3', video_id, f4m_id=format_id, fatal=False))
143 # the secret extracted ya function in http://player.canalplus.fr/common/js/canalPlayer.js
144 'url': format_url + '?secret=pqzerjlsmdkjfoiuerhsdlfknaes',
145 'format_id': format_id,
146 'preference': preference(format_id),
148 self._sort_formats(formats)
153 } for image_id, image_url in media.get('images', {}).items()]
155 titrage = infos['TITRAGE']
159 'display_id': display_id,
160 'title': '%s - %s' % (titrage['TITRE'],
161 titrage['SOUS_TITRE']),
162 'upload_date': unified_strdate(infos.get('PUBLICATION', {}).get('DATE')),
163 'thumbnails': thumbnails,
164 'description': infos.get('DESCRIPTION'),
165 'duration': int_or_none(infos.get('DURATION')),
166 'view_count': int_or_none(infos.get('NB_VUES')),
167 'like_count': int_or_none(infos.get('NB_LIKES')),
168 'comment_count': int_or_none(infos.get('NB_COMMENTS')),