Merge pull request #1036 from yasoob/master
[youtube-dl] / youtube_dl / extractor / criterion.py
1 # -*- coding: utf-8 -*-
2
3 import re
4
5 from .common import InfoExtractor
6
7 class CriterionIE(InfoExtractor):
8     _VALID_URL = r'http://www.criterion.com/films/(.*)'
9     _TEST = {
10         u'url': u'http://www.criterion.com/films/184-le-samourai',
11         u'file': u'184.mp4',
12         u'md5': u'bc51beba55685509883a9a7830919ec3',
13         u'info_dict': {
14             u"title": u"Le Samouraï",
15             u"description" : u"In a career-defining performance, Alain Delon plays a contract killer with samurai instincts. A razor-sharp cocktail of 1940s American gangster cinema and 1960s French pop culture, maverick director Jean-Pierre Melville's masterpiece _Le Samouraï_ defines cool. "
16         }
17     }
18
19     def _real_extract(self, url):
20         mobj = re.match(self._VALID_URL, url)
21         video_id = mobj.group(1).split('-')[0]
22         webpage = self._download_webpage(url, video_id)
23
24         final_url = self._search_regex(r'so.addVariable\("videoURL", "(.+?)"\)\;',
25                                 webpage, 'video url')
26         title = self._search_regex(r'<meta content="(.+?)" property="og:title" />',
27                                 webpage, 'video title')
28         description = self._search_regex(r'<meta name="description" content="(.+?)" />',
29                                 webpage, 'video description')
30         thumbnail = self._search_regex(r'so.addVariable\("thumbnailURL", "(.+?)"\)\;',
31                                 webpage, 'thumbnail url')
32         ext = final_url.split('.')[-1]
33
34         return {'id': video_id,
35                 'url' : final_url,
36                 'title': title,
37                 'ext': ext,
38                 'description': description,
39                 'thumbnail': thumbnail,
40                 }