]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/canalplus.py
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
  13 class CanalplusIE(InfoExtractor
): 
  14     _VALID_URL 
= r
'https?://(?:www\.canalplus\.fr/.*?/(?P<path>.*)|player\.canalplus\.fr/#/(?P<id>[0-9]+))' 
  15     _VIDEO_INFO_TEMPLATE 
= 'http://service.canal-plus.com/video/rest/getVideosLiees/cplus/%s' 
  16     IE_NAME 
= 'canalplus.fr' 
  19         'url': 'http://www.canalplus.fr/c-infos-documentaires/pid1830-c-zapping.html?vid=922470', 
  20         'md5': '3db39fb48b9685438ecf33a1078023e4', 
  24             'title': 'Zapping - 26/08/13', 
  25             'description': 'Le meilleur de toutes les chaînes, tous les jours.\nEmission du 26 août 2013', 
  26             'upload_date': '20130826', 
  30     def _real_extract(self
, url
): 
  31         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  32         video_id 
= mobj
.groupdict().get('id') 
  34         # Beware, some subclasses do not define an id group 
  35         display_id 
= url_basename(mobj
.group('path')) 
  38             webpage 
= self
._download
_webpage
(url
, display_id
) 
  39             video_id 
= self
._search
_regex
(r
'<canal:player videoId="(\d+)"', webpage
, 'video id') 
  41         info_url 
= self
._VIDEO
_INFO
_TEMPLATE 
% video_id
 
  42         doc 
= self
._download
_xml
(info_url
, video_id
, 'Downloading video XML') 
  44         video_info 
= [video 
for video 
in doc 
if video
.find('ID').text 
== video_id
][0] 
  45         media 
= video_info
.find('MEDIA') 
  46         infos 
= video_info
.find('INFOS') 
  48         preferences 
= ['MOBILE', 'BAS_DEBIT', 'HAUT_DEBIT', 'HD', 'HLS', 'HDS'] 
  52                 'url': fmt
.text 
+ '?hdcore=2.11.3' if fmt
.tag 
== 'HDS' else fmt
.text
, 
  54                 'ext': 'mp4' if fmt
.tag 
== 'HLS' else 'flv', 
  55                 'preference': preferences
.index(fmt
.tag
) if fmt
.tag 
in preferences 
else -1, 
  56             } for fmt 
in media
.find('VIDEOS') if fmt
.text
 
  58         self
._sort
_formats
(formats
) 
  62             'display_id': display_id
, 
  63             'title': '%s - %s' % (infos
.find('TITRAGE/TITRE').text
, 
  64                                   infos
.find('TITRAGE/SOUS_TITRE').text
), 
  65             'upload_date': unified_strdate(infos
.find('PUBLICATION/DATE').text
), 
  66             'thumbnail': media
.find('IMAGES/GRAND').text
, 
  67             'description': infos
.find('DESCRIPTION').text
, 
  68             'view_count': int(infos
.find('NB_VUES').text
), 
  69             'like_count': int(infos
.find('NB_LIKES').text
), 
  70             'comment_count': int(infos
.find('NB_COMMENTS').text
),