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