]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cultureunplugged.py
Update the changelog.
[youtubedl] / youtube_dl / extractor / cultureunplugged.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import int_or_none
7
8
9 class CultureUnpluggedIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?cultureunplugged\.com/documentary/watch-online/play/(?P<id>\d+)(?:/(?P<display_id>[^/]+))?'
11 _TESTS = [{
12 'url': 'http://www.cultureunplugged.com/documentary/watch-online/play/53662/The-Next--Best-West',
13 'md5': 'ac6c093b089f7d05e79934dcb3d228fc',
14 'info_dict': {
15 'id': '53662',
16 'display_id': 'The-Next--Best-West',
17 'ext': 'mp4',
18 'title': 'The Next, Best West',
19 'description': 'md5:0423cd00833dea1519cf014e9d0903b1',
20 'thumbnail': 're:^https?://.*\.jpg$',
21 'creator': 'Coldstream Creative',
22 'duration': 2203,
23 'view_count': int,
24 }
25 }, {
26 'url': 'http://www.cultureunplugged.com/documentary/watch-online/play/53662',
27 'only_matching': True,
28 }]
29
30 def _real_extract(self, url):
31 mobj = re.match(self._VALID_URL, url)
32 video_id = mobj.group('id')
33 display_id = mobj.group('display_id') or video_id
34
35 movie_data = self._download_json(
36 'http://www.cultureunplugged.com/movie-data/cu-%s.json' % video_id, display_id)
37
38 video_url = movie_data['url']
39 title = movie_data['title']
40
41 description = movie_data.get('synopsis')
42 creator = movie_data.get('producer')
43 duration = int_or_none(movie_data.get('duration'))
44 view_count = int_or_none(movie_data.get('views'))
45
46 thumbnails = [{
47 'url': movie_data['%s_thumb' % size],
48 'id': size,
49 'preference': preference,
50 } for preference, size in enumerate((
51 'small', 'large')) if movie_data.get('%s_thumb' % size)]
52
53 return {
54 'id': video_id,
55 'display_id': display_id,
56 'url': video_url,
57 'title': title,
58 'description': description,
59 'creator': creator,
60 'duration': duration,
61 'view_count': view_count,
62 'thumbnails': thumbnails,
63 }