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',
20 'title': 'Zapping - 26/08/13',
21 'description': 'Le meilleur de toutes les chaînes, tous les jours.\nEmission du 26 août 2013',
22 'upload_date': '20130826',
25 'skip_download': True,
29 def _real_extract(self, url):
30 mobj = re.match(self._VALID_URL, url)
31 video_id = mobj.group('id')
34 webpage = self._download_webpage(url, mobj.group('path'))
35 video_id = self._search_regex(r'<canal:player videoId="(\d+)"', webpage, 'video id')
37 info_url = self._VIDEO_INFO_TEMPLATE % video_id
38 doc = self._download_xml(info_url, video_id, 'Downloading video XML')
40 video_info = [video for video in doc if video.find('ID').text == video_id][0]
41 media = video_info.find('MEDIA')
42 infos = video_info.find('INFOS')
44 preferences = ['MOBILE', 'BAS_DEBIT', 'HAUT_DEBIT', 'HD', 'HLS', 'HDS']
48 'url': fmt.text + '?hdcore=2.11.3' if fmt.tag == 'HDS' else fmt.text,
50 'ext': 'mp4' if fmt.tag == 'HLS' else 'flv',
51 'preference': preferences.index(fmt.tag) if fmt.tag in preferences else -1,
52 } for fmt in media.find('VIDEOS') if fmt.text
54 self._sort_formats(formats)
58 'title': '%s - %s' % (infos.find('TITRAGE/TITRE').text,
59 infos.find('TITRAGE/SOUS_TITRE').text),
60 'upload_date': unified_strdate(infos.find('PUBLICATION/DATE').text),
61 'thumbnail': media.find('IMAGES/GRAND').text,
62 'description': infos.find('DESCRIPTION').text,
63 'view_count': int(infos.find('NB_VUES').text),
64 'like_count': int(infos.find('NB_LIKES').text),
65 'comment_count': int(infos.find('NB_COMMENTS').text),