2 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 class CanalplusIE(InfoExtractor):
14 IE_DESC = 'canalplus.fr and piwiplus.fr'
15 _VALID_URL = r'https?://(?:www\.(?P<site>canal|piwi)plus\.fr/.*?/(?P<path>.*)|player\.canalplus\.fr/#/(?P<id>[0-9]+))'
16 _VIDEO_INFO_TEMPLATE = 'http://service.canal-plus.com/video/rest/getVideosLiees/%s/%s'
23 'url': 'http://www.canalplus.fr/c-infos-documentaires/pid1830-c-zapping.html?vid=922470',
24 'md5': '3db39fb48b9685438ecf33a1078023e4',
28 'title': 'Zapping - 26/08/13',
29 'description': 'Le meilleur de toutes les chaînes, tous les jours.\nEmission du 26 août 2013',
30 'upload_date': '20130826',
33 'url': 'http://www.piwiplus.fr/videos-piwi/pid1405-le-labyrinthe-boing-super-ranger.html?vid=1108190',
34 'md5': '3db39fb48b9685438ecf33a1078023e4',
38 'title': 'Le labyrinthe - Boing super ranger',
39 'description': 'md5:',
40 'upload_date': '20140724',
44 def _real_extract(self, url):
45 mobj = re.match(self._VALID_URL, url)
46 video_id = mobj.groupdict().get('id')
48 site_id = self._SITE_ID_MAP[mobj.group('site') or 'canal']
50 # Beware, some subclasses do not define an id group
51 display_id = url_basename(mobj.group('path'))
54 webpage = self._download_webpage(url, display_id)
55 video_id = self._search_regex(
56 r'<canal:player[^>]+?videoId="(\d+)"', webpage, 'video id')
58 info_url = self._VIDEO_INFO_TEMPLATE % (site_id, video_id)
59 doc = self._download_xml(info_url, video_id, 'Downloading video XML')
61 video_info = [video for video in doc if video.find('ID').text == video_id][0]
62 media = video_info.find('MEDIA')
63 infos = video_info.find('INFOS')
65 preferences = ['MOBILE', 'BAS_DEBIT', 'HAUT_DEBIT', 'HD', 'HLS', 'HDS']
69 'url': fmt.text + '?hdcore=2.11.3' if fmt.tag == 'HDS' else fmt.text,
71 'ext': 'mp4' if fmt.tag == 'HLS' else 'flv',
72 'preference': preferences.index(fmt.tag) if fmt.tag in preferences else -1,
73 } for fmt in media.find('VIDEOS') if fmt.text
75 self._sort_formats(formats)
79 'display_id': display_id,
80 'title': '%s - %s' % (infos.find('TITRAGE/TITRE').text,
81 infos.find('TITRAGE/SOUS_TITRE').text),
82 'upload_date': unified_strdate(infos.find('PUBLICATION/DATE').text),
83 'thumbnail': media.find('IMAGES/GRAND').text,
84 'description': infos.find('DESCRIPTION').text,
85 'view_count': int(infos.find('NB_VUES').text),
86 'like_count': int(infos.find('NB_LIKES').text),
87 'comment_count': int(infos.find('NB_COMMENTS').text),