2 from __future__ import unicode_literals
4 from .common import InfoExtractor
11 class AllocineIE(InfoExtractor):
12 _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)?'
15 'url': 'http://www.allocine.fr/article/fichearticle_gen_carticle=18635087.html',
16 'md5': '0c9fcf59a841f65635fa300ac43d8269',
19 'display_id': '18635087',
21 'title': 'Astérix - Le Domaine des Dieux Teaser VF',
22 'description': 'md5:4a754271d9c6f16c72629a8a993ee884',
23 'thumbnail': 're:http://.*\.jpg',
26 'url': 'http://www.allocine.fr/video/player_gen_cmedia=19540403&cfilm=222257.html',
27 'md5': 'd0cdce5d2b9522ce279fdfec07ff16e0',
30 'display_id': '19540403',
32 'title': 'Planes 2 Bande-annonce VF',
33 'description': 'Regardez la bande annonce du film Planes 2 (Planes 2 Bande-annonce VF). Planes 2, un film de Roberts Gannaway',
34 'thumbnail': 're:http://.*\.jpg',
37 'url': 'http://www.allocine.fr/video/player_gen_cmedia=19544709&cfilm=181290.html',
38 'md5': '101250fb127ef9ca3d73186ff22a47ce',
41 'display_id': '19544709',
43 'title': 'Dragons 2 - Bande annonce finale VF',
44 'description': 'md5:6cdd2d7c2687d4c6aafe80a35e17267a',
45 'thumbnail': 're:http://.*\.jpg',
48 'url': 'http://www.allocine.fr/video/video-19550147/',
49 'only_matching': True,
52 def _real_extract(self, url):
53 display_id = self._match_id(url)
55 webpage = self._download_webpage(url, display_id)
57 model = self._html_search_regex(
58 r'data-model="([^"]+)"', webpage, 'data model')
59 model_data = self._parse_json(model, display_id)
61 quality = qualities(['ld', 'md', 'hd'])
64 for video_url in model_data['sources'].values():
65 video_id, format_id = url_basename(video_url).split('_')[:2]
67 'format_id': format_id,
68 'quality': quality(format_id),
71 self._sort_formats(formats)
75 'display_id': display_id,
76 'title': model_data['title'],
77 'thumbnail': self._og_search_thumbnail(webpage),
79 'description': self._og_search_description(webpage),