]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/canalplus.py
11d18d74ace31a513a7c06be40baf6ce89c858b3
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)/.*?/(?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',
27 'url': 'http://www.canalplus.fr/c-infos-documentaires/pid1830-c-zapping.html?vid=922470',
28 'md5': '3db39fb48b9685438ecf33a1078023e4',
32 'title': 'Zapping - 26/08/13',
33 'description': 'Le meilleur de toutes les chaînes, tous les jours.\nEmission du 26 août 2013',
34 'upload_date': '20130826',
37 'url': 'http://www.piwiplus.fr/videos-piwi/pid1405-le-labyrinthe-boing-super-ranger.html?vid=1108190',
41 'title': 'Le labyrinthe - Boing super ranger',
42 'description': 'md5:4cea7a37153be42c1ba2c1d3064376ff',
43 'upload_date': '20140724',
45 'skip': 'Only works from France',
47 'url': 'http://www.d8.tv/d8-docs-mags/pid6589-d8-campagne-intime.html',
51 'title': 'Campagne intime - Documentaire exceptionnel',
52 'description': 'md5:d2643b799fb190846ae09c61e59a859f',
53 'upload_date': '20131108',
55 'skip': 'videos get deleted after a while',
58 def _real_extract(self
, url
):
59 mobj
= re
.match(self
._VALID
_URL
, url
)
60 video_id
= mobj
.groupdict().get('id')
62 site_id
= self
._SITE
_ID
_MAP
[mobj
.group('site') or 'canal']
64 # Beware, some subclasses do not define an id group
65 display_id
= url_basename(mobj
.group('path'))
68 webpage
= self
._download
_webpage
(url
, display_id
)
69 video_id
= self
._search
_regex
(
70 r
'<canal:player[^>]+?videoId="(\d+)"', webpage
, 'video id')
72 info_url
= self
._VIDEO
_INFO
_TEMPLATE
% (site_id
, video_id
)
73 doc
= self
._download
_xml
(info_url
, video_id
, 'Downloading video XML')
75 video_info
= [video
for video
in doc
if video
.find('ID').text
== video_id
][0]
76 media
= video_info
.find('MEDIA')
77 infos
= video_info
.find('INFOS')
79 preference
= qualities(['MOBILE', 'BAS_DEBIT', 'HAUT_DEBIT', 'HD', 'HLS', 'HDS'])
81 fmt_url
= next(iter(media
.find('VIDEOS'))).text
82 if '/geo' in fmt_url
.lower():
83 response
= self
._request
_webpage
(
84 HEADRequest(fmt_url
), video_id
,
85 'Checking if the video is georestricted')
86 if '/blocage' in response
.geturl():
88 'The video is not available in your country',
92 for fmt
in media
.find('VIDEOS'):
97 if format_id
== 'HLS':
98 hls_formats
= self
._extract
_m
3u8_formats
(format_url
, video_id
, 'flv')
99 for fmt
in hls_formats
:
100 fmt
['preference'] = preference(format_id
)
101 formats
.extend(hls_formats
)
102 elif format_id
== 'HDS':
103 hds_formats
= self
._extract
_f
4m
_formats
(format_url
+ '?hdcore=2.11.3', video_id
)
104 for fmt
in hds_formats
:
105 fmt
['preference'] = preference(format_id
)
106 formats
.extend(hds_formats
)
110 'format_id': format_id
,
111 'preference': preference(format_id
),
113 self
._sort
_formats
(formats
)
117 'display_id': display_id
,
118 'title': '%s - %s' % (infos
.find('TITRAGE/TITRE').text
,
119 infos
.find('TITRAGE/SOUS_TITRE').text
),
120 'upload_date': unified_strdate(infos
.find('PUBLICATION/DATE').text
),
121 'thumbnail': media
.find('IMAGES/GRAND').text
,
122 'description': infos
.find('DESCRIPTION').text
,
123 'view_count': int(infos
.find('NB_VUES').text
),
124 'like_count': int(infos
.find('NB_LIKES').text
),
125 'comment_count': int(infos
.find('NB_COMMENTS').text
),