]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/canalplus.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
16 class CanalplusIE(InfoExtractor
):
17 IE_DESC
= 'canalplus.fr, piwiplus.fr and d8.tv'
18 _VALID_URL
= r
'https?://(?:www\.(?P<site>canalplus\.fr|piwiplus\.fr|d8\.tv|itele\.fr)/.*?/(?P<path>.*)|player\.canalplus\.fr/#/(?P<id>[0-9]+))'
19 _VIDEO_INFO_TEMPLATE
= 'http://service.canal-plus.com/video/rest/getVideosLiees/%s/%s'
21 'canalplus.fr': 'cplus',
22 'piwiplus.fr': 'teletoon',
28 'url': 'http://www.canalplus.fr/c-emissions/pid1830-c-zapping.html?vid=1263092',
29 'md5': 'b3481d7ca972f61e37420798d0a9d934',
33 'title': 'Le Zapping - 13/05/15',
34 'description': 'md5:09738c0d06be4b5d06a0940edb0da73f',
35 'upload_date': '20150513',
38 'url': 'http://www.piwiplus.fr/videos-piwi/pid1405-le-labyrinthe-boing-super-ranger.html?vid=1108190',
42 'title': 'Le labyrinthe - Boing super ranger',
43 'description': 'md5:4cea7a37153be42c1ba2c1d3064376ff',
44 'upload_date': '20140724',
46 'skip': 'Only works from France',
48 'url': 'http://www.d8.tv/d8-docs-mags/pid6589-d8-campagne-intime.html',
52 'title': 'Campagne intime - Documentaire exceptionnel',
53 'description': 'md5:d2643b799fb190846ae09c61e59a859f',
54 'upload_date': '20131108',
56 'skip': 'videos get deleted after a while',
58 'url': 'http://www.itele.fr/france/video/aubervilliers-un-lycee-en-colere-111559',
59 'md5': 'f3a46edcdf28006598ffaf5b30e6a2d4',
63 'title': 'Aubervilliers : un lycée en colère - Le 11/02/2015 à 06h45',
64 'description': 'md5:8216206ec53426ea6321321f3b3c16db',
65 'upload_date': '20150211',
69 def _real_extract(self
, url
):
70 mobj
= re
.match(self
._VALID
_URL
, url
)
71 video_id
= mobj
.groupdict().get('id')
73 site_id
= self
._SITE
_ID
_MAP
[mobj
.group('site') or 'canal']
75 # Beware, some subclasses do not define an id group
76 display_id
= url_basename(mobj
.group('path'))
79 webpage
= self
._download
_webpage
(url
, display_id
)
80 video_id
= self
._search
_regex
(
81 [r
'<canal:player[^>]+?videoId=(["\'])(?P
<id>\d
+)', r'id=["\']canal_video_player(?P<id>\d+)'],
82 webpage, 'video id', group='id')
84 info_url = self._VIDEO_INFO_TEMPLATE % (site_id, video_id)
85 doc = self._download_xml(info_url, video_id, 'Downloading video XML')
87 video_info = [video for video in doc if video.find('ID').text == video_id][0]
88 media = video_info.find('MEDIA')
89 infos = video_info.find('INFOS')
91 preference = qualities(['MOBILE', 'BAS_DEBIT', 'HAUT_DEBIT', 'HD', 'HLS', 'HDS'])
93 fmt_url = next(iter(media.find('VIDEOS'))).text
94 if '/geo' in fmt_url.lower():
95 response = self._request_webpage(
96 HEADRequest(fmt_url), video_id,
97 'Checking if the video is georestricted')
98 if '/blocage' in response.geturl():
100 'The video is not available in your country',
104 for fmt in media.find('VIDEOS'):
105 format_url = fmt.text
109 if format_id == 'HLS':
110 formats.extend(self._extract_m3u8_formats(
111 format_url, video_id, 'mp4', preference=preference(format_id)))
112 elif format_id == 'HDS':
113 formats.extend(self._extract_f4m_formats(
114 format_url + '?hdcore=2.11.3', video_id, preference=preference(format_id)))
118 'format_id': format_id,
119 'preference': preference(format_id),
121 self._sort_formats(formats)
125 'display_id': display_id,
126 'title': '%s - %s' % (infos.find('TITRAGE/TITRE').text,
127 infos.find('TITRAGE/SOUS_TITRE').text),
128 'upload_date': unified_strdate(infos.find('PUBLICATION/DATE').text),
129 'thumbnail': media.find('IMAGES/GRAND').text,
130 'description': infos.find('DESCRIPTION').text,
131 'view_count': int(infos.find('NB_VUES').text),
132 'like_count': int(infos.find('NB_LIKES').text),
133 'comment_count': int(infos.find('NB_COMMENTS').text),