]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/canalplus.py
9873728df6f3bb1adbfddc1959aa5e7e70241f5b
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
14 class CanalplusIE(InfoExtractor
):
15 IE_DESC
= 'canalplus.fr, piwiplus.fr and d8.tv'
16 _VALID_URL
= r
'https?://(?:www\.(?P<site>canalplus\.fr|piwiplus\.fr|d8\.tv)/.*?/(?P<path>.*)|player\.canalplus\.fr/#/(?P<id>[0-9]+))'
17 _VIDEO_INFO_TEMPLATE
= 'http://service.canal-plus.com/video/rest/getVideosLiees/%s/%s'
19 'canalplus.fr': 'cplus',
20 'piwiplus.fr': 'teletoon',
25 'url': 'http://www.canalplus.fr/c-infos-documentaires/pid1830-c-zapping.html?vid=922470',
26 'md5': '3db39fb48b9685438ecf33a1078023e4',
30 'title': 'Zapping - 26/08/13',
31 'description': 'Le meilleur de toutes les chaînes, tous les jours.\nEmission du 26 août 2013',
32 'upload_date': '20130826',
35 'url': 'http://www.piwiplus.fr/videos-piwi/pid1405-le-labyrinthe-boing-super-ranger.html?vid=1108190',
39 'title': 'Le labyrinthe - Boing super ranger',
40 'description': 'md5:4cea7a37153be42c1ba2c1d3064376ff',
41 'upload_date': '20140724',
43 'skip': 'Only works from France',
45 'url': 'http://www.d8.tv/d8-docs-mags/pid6589-d8-campagne-intime.html',
49 'title': 'Campagne intime - Documentaire exceptionnel',
50 'description': 'md5:d2643b799fb190846ae09c61e59a859f',
51 'upload_date': '20131108',
53 'skip': 'videos get deleted after a while',
56 def _real_extract(self
, url
):
57 mobj
= re
.match(self
._VALID
_URL
, url
)
58 video_id
= mobj
.groupdict().get('id')
60 site_id
= self
._SITE
_ID
_MAP
[mobj
.group('site') or 'canal']
62 # Beware, some subclasses do not define an id group
63 display_id
= url_basename(mobj
.group('path'))
66 webpage
= self
._download
_webpage
(url
, display_id
)
67 video_id
= self
._search
_regex
(
68 r
'<canal:player[^>]+?videoId="(\d+)"', webpage
, 'video id')
70 info_url
= self
._VIDEO
_INFO
_TEMPLATE
% (site_id
, video_id
)
71 doc
= self
._download
_xml
(info_url
, video_id
, 'Downloading video XML')
73 video_info
= [video
for video
in doc
if video
.find('ID').text
== video_id
][0]
74 media
= video_info
.find('MEDIA')
75 infos
= video_info
.find('INFOS')
77 preference
= qualities(['MOBILE', 'BAS_DEBIT', 'HAUT_DEBIT', 'HD', 'HLS', 'HDS'])
80 for fmt
in media
.find('VIDEOS'):
85 if format_id
== 'HLS':
86 hls_formats
= self
._extract
_m
3u8_formats
(format_url
, video_id
, 'flv')
87 for fmt
in hls_formats
:
88 fmt
['preference'] = preference(format_id
)
89 formats
.extend(hls_formats
)
90 elif format_id
== 'HDS':
91 hds_formats
= self
._extract
_f
4m
_formats
(format_url
+ '?hdcore=2.11.3', video_id
)
92 for fmt
in hds_formats
:
93 fmt
['preference'] = preference(format_id
)
94 formats
.extend(hds_formats
)
98 'format_id': format_id
,
99 'preference': preference(format_id
),
101 self
._sort
_formats
(formats
)
105 'display_id': display_id
,
106 'title': '%s - %s' % (infos
.find('TITRAGE/TITRE').text
,
107 infos
.find('TITRAGE/SOUS_TITRE').text
),
108 'upload_date': unified_strdate(infos
.find('PUBLICATION/DATE').text
),
109 'thumbnail': media
.find('IMAGES/GRAND').text
,
110 'description': infos
.find('DESCRIPTION').text
,
111 'view_count': int(infos
.find('NB_VUES').text
),
112 'like_count': int(infos
.find('NB_LIKES').text
),
113 'comment_count': int(infos
.find('NB_COMMENTS').text
),