]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/criterion.py
Imported Upstream version 2014.06.07
[youtubedl] / youtube_dl / extractor / criterion.py
1 # -*- coding: utf-8 -*-
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import determine_ext
7
8 class CriterionIE(InfoExtractor):
9 _VALID_URL = r'https?://www\.criterion\.com/films/(\d*)-.+'
10 _TEST = {
11 u'url': u'http://www.criterion.com/films/184-le-samourai',
12 u'file': u'184.mp4',
13 u'md5': u'bc51beba55685509883a9a7830919ec3',
14 u'info_dict': {
15 u"title": u"Le Samouraï",
16 u"description" : u'md5:a2b4b116326558149bef81f76dcbb93f',
17 }
18 }
19
20 def _real_extract(self, url):
21 mobj = re.match(self._VALID_URL, url)
22 video_id = mobj.group(1)
23 webpage = self._download_webpage(url, video_id)
24
25 final_url = self._search_regex(r'so.addVariable\("videoURL", "(.+?)"\)\;',
26 webpage, 'video url')
27 title = self._html_search_regex(r'<meta content="(.+?)" property="og:title" />',
28 webpage, 'video title')
29 description = self._html_search_regex(r'<meta name="description" content="(.+?)" />',
30 webpage, 'video description')
31 thumbnail = self._search_regex(r'so.addVariable\("thumbnailURL", "(.+?)"\)\;',
32 webpage, 'thumbnail url')
33
34 return {'id': video_id,
35 'url' : final_url,
36 'title': title,
37 'ext': determine_ext(final_url),
38 'description': description,
39 'thumbnail': thumbnail,
40 }