]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/canalplus.py
3 import xml
.etree
.ElementTree
5 from .common
import InfoExtractor
6 from ..utils
import unified_strdate
9 class CanalplusIE(InfoExtractor
):
10 _VALID_URL
= r
'https?://(www\.canalplus\.fr/.*?/(?P<path>.*)|player\.canalplus\.fr/#/(?P<id>\d+))'
11 _VIDEO_INFO_TEMPLATE
= 'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/%s'
12 IE_NAME
= u
'canalplus.fr'
15 u
'url': u
'http://www.canalplus.fr/c-infos-documentaires/pid1830-c-zapping.html?vid=922470',
16 u
'file': u
'922470.flv',
18 u
'title': u
'Zapping - 26/08/13',
19 u
'description': u
'Le meilleur de toutes les chaînes, tous les jours.\nEmission du 26 août 2013',
20 u
'upload_date': u
'20130826',
23 u
'skip_download': True,
27 def _real_extract(self
, url
):
28 mobj
= re
.match(self
._VALID
_URL
, url
)
29 video_id
= mobj
.groupdict().get('id')
31 webpage
= self
._download
_webpage
(url
, mobj
.group('path'))
32 video_id
= self
._search
_regex
(r
'videoId = "(\d+)";', webpage
, u
'video id')
33 info_url
= self
._VIDEO
_INFO
_TEMPLATE
% video_id
34 info_page
= self
._download
_webpage
(info_url
,video_id
,
35 u
'Downloading video info')
37 self
.report_extraction(video_id
)
38 doc
= xml
.etree
.ElementTree
.fromstring(info_page
.encode('utf-8'))
39 video_info
= [video
for video
in doc
if video
.find('ID').text
== video_id
][0]
40 infos
= video_info
.find('INFOS')
41 media
= video_info
.find('MEDIA')
42 formats
= [media
.find('VIDEOS/%s' % format
)
43 for format
in ['BAS_DEBIT', 'HAUT_DEBIT', 'HD']]
44 video_url
= [format
.text
for format
in formats
if format
is not None][-1]
46 return {'id': video_id
,
47 'title': u
'%s - %s' % (infos
.find('TITRAGE/TITRE').text
,
48 infos
.find('TITRAGE/SOUS_TITRE').text
),
51 'upload_date': unified_strdate(infos
.find('PUBLICATION/DATE').text
),
52 'thumbnail': media
.find('IMAGES/GRAND').text
,
53 'description': infos
.find('DESCRIPTION').text
,
54 'view_count': int(infos
.find('NB_VUES').text
),