added an IE for criterion.com
[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
10     def _real_extract(self, url):
11         mobj = re.match(self._VALID_URL, url)
12         video_id = mobj.group(1).split('-')[0]
13         webpage = self._download_webpage(url, video_id)
14
15         final_url = self._search_regex(r'so.addVariable\("videoURL", "(.+?)"\)\;',
16                                 webpage, 'video url')
17         title = self._search_regex(r'<meta content="(.+?)" property="og:title" />',
18                                 webpage, 'video title')
19         description = self._search_regex(r'<meta name="description" content="(.+?)" />',
20                                 webpage, 'video description')
21         thumbnail = self._search_regex(r'so.addVariable\("thumbnailURL", "(.+?)"\)\;',
22                                 webpage, 'thumbnail url')
23         ext = final_url.split('.')[-1]
24
25         return {'id': video_id,
26                 'url' : final_url,
27                 'title': title,
28                 'ext': ext,
29                 'description': description,
30                 'thumbnail': thumbnail,
31                 }