2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..utils import unified_strdate
10 class CanalplusIE(InfoExtractor):
11 _VALID_URL = r'https?://(www\.canalplus\.fr/.*?/(?P<path>.*)|player\.canalplus\.fr/#/(?P<id>\d+))'
12 _VIDEO_INFO_TEMPLATE = 'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/%s'
13 IE_NAME = 'canalplus.fr'
16 'url': 'http://www.canalplus.fr/c-infos-documentaires/pid1830-c-zapping.html?vid=922470',
17 'md5': '60c29434a416a83c15dae2587d47027d',
21 'title': 'Zapping - 26/08/13',
22 'description': 'Le meilleur de toutes les chaînes, tous les jours.\nEmission du 26 août 2013',
23 'upload_date': '20130826',
27 def _real_extract(self, url):
28 mobj = re.match(self._VALID_URL, url)
29 video_id = mobj.group('id')
32 webpage = self._download_webpage(url, mobj.group('path'))
33 video_id = self._search_regex(r'<canal:player videoId="(\d+)"', webpage, 'video id')
35 info_url = self._VIDEO_INFO_TEMPLATE % video_id
36 doc = self._download_xml(info_url, video_id, 'Downloading video XML')
38 video_info = [video for video in doc if video.find('ID').text == video_id][0]
39 media = video_info.find('MEDIA')
40 infos = video_info.find('INFOS')
42 preferences = ['MOBILE', 'BAS_DEBIT', 'HAUT_DEBIT', 'HD', 'HLS', 'HDS']
46 'url': fmt.text + '?hdcore=2.11.3' if fmt.tag == 'HDS' else fmt.text,
48 'ext': 'mp4' if fmt.tag == 'HLS' else 'flv',
49 'preference': preferences.index(fmt.tag) if fmt.tag in preferences else -1,
50 } for fmt in media.find('VIDEOS') if fmt.text
52 self._sort_formats(formats)
56 'title': '%s - %s' % (infos.find('TITRAGE/TITRE').text,
57 infos.find('TITRAGE/SOUS_TITRE').text),
58 'upload_date': unified_strdate(infos.find('PUBLICATION/DATE').text),
59 'thumbnail': media.find('IMAGES/GRAND').text,
60 'description': infos.find('DESCRIPTION').text,
61 'view_count': int(infos.find('NB_VUES').text),
62 'like_count': int(infos.find('NB_LIKES').text),
63 'comment_count': int(infos.find('NB_COMMENTS').text),