]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/allocine.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  12 class AllocineIE(InfoExtractor
): 
  13     _VALID_URL 
= r
'https?://(?:www\.)?allocine\.fr/(?:article|video|film)/(?:fichearticle_gen_carticle=|player_gen_cmedia=|fichefilm_gen_cfilm=|video-)(?P<id>[0-9]+)(?:\.html)?' 
  16         'url': 'http://www.allocine.fr/article/fichearticle_gen_carticle=18635087.html', 
  17         'md5': '0c9fcf59a841f65635fa300ac43d8269', 
  20             'display_id': '18635087', 
  22             'title': 'Astérix - Le Domaine des Dieux Teaser VF', 
  23             'description': 'md5:4a754271d9c6f16c72629a8a993ee884', 
  24             'thumbnail': 're:http://.*\.jpg', 
  27         'url': 'http://www.allocine.fr/video/player_gen_cmedia=19540403&cfilm=222257.html', 
  28         'md5': 'd0cdce5d2b9522ce279fdfec07ff16e0', 
  31             'display_id': '19540403', 
  33             'title': 'Planes 2 Bande-annonce VF', 
  34             'description': 'Regardez la bande annonce du film Planes 2 (Planes 2 Bande-annonce VF). Planes 2, un film de Roberts Gannaway', 
  35             'thumbnail': 're:http://.*\.jpg', 
  38         'url': 'http://www.allocine.fr/video/player_gen_cmedia=19544709&cfilm=181290.html', 
  39         'md5': '101250fb127ef9ca3d73186ff22a47ce', 
  42             'display_id': '19544709', 
  44             'title': 'Dragons 2 - Bande annonce finale VF', 
  45             'description': 'md5:6cdd2d7c2687d4c6aafe80a35e17267a', 
  46             'thumbnail': 're:http://.*\.jpg', 
  49         'url': 'http://www.allocine.fr/video/video-19550147/', 
  50         'md5': '3566c0668c0235e2d224fd8edb389f67', 
  54             'title': 'Faux Raccord N°123 - Les gaffes de Cliffhanger', 
  55             'description': 'md5:bc734b83ffa2d8a12188d9eb48bb6354', 
  56             'thumbnail': 're:http://.*\.jpg', 
  60     def _real_extract(self
, url
): 
  61         display_id 
= self
._match
_id
(url
) 
  63         webpage 
= self
._download
_webpage
(url
, display_id
) 
  66         quality 
= qualities(['ld', 'md', 'hd']) 
  68         model 
= self
._html
_search
_regex
( 
  69             r
'data-model="([^"]+)"', webpage
, 'data model', default
=None) 
  71             model_data 
= self
._parse
_json
(model
, display_id
) 
  73             for video_url 
in model_data
['sources'].values(): 
  74                 video_id
, format_id 
= url_basename(video_url
).split('_')[:2] 
  76                     'format_id': format_id
, 
  77                     'quality': quality(format_id
), 
  81             title 
= model_data
['title'] 
  84             media_data 
= self
._download
_json
( 
  85                 'http://www.allocine.fr/ws/AcVisiondataV5.ashx?media=%s' % video_id
, display_id
) 
  86             for key
, value 
in media_data
['video'].items(): 
  87                 if not key
.endswith('Path'): 
  90                 format_id 
= key
[:-len('Path')] 
  92                     'format_id': format_id
, 
  93                     'quality': quality(format_id
), 
  97             title 
= remove_end(self
._html
_search
_regex
( 
  98                 r
'(?s)<title>(.+?)</title>', webpage
, 'title' 
  99             ).strip(), ' - AlloCiné') 
 101         self
._sort
_formats
(formats
) 
 105             'display_id': display_id
, 
 107             'thumbnail': self
._og
_search
_thumbnail
(webpage
), 
 109             'description': self
._og
_search
_description
(webpage
),