]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/cultureunplugged.py
[youtube] Prefer UTC upload date for videos (#2223)
[yt-dlp.git] / yt_dlp / extractor / cultureunplugged.py
CommitLineData
a50a8003
S
1from __future__ import unicode_literals
2
e25586e4 3import time
a50a8003
S
4
5from .common import InfoExtractor
e25586e4
RA
6from ..utils import (
7 int_or_none,
8 HEADRequest,
9)
a50a8003
S
10
11
12class CultureUnpluggedIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:www\.)?cultureunplugged\.com/documentary/watch-online/play/(?P<id>\d+)(?:/(?P<display_id>[^/]+))?'
14 _TESTS = [{
15 'url': 'http://www.cultureunplugged.com/documentary/watch-online/play/53662/The-Next--Best-West',
16 'md5': 'ac6c093b089f7d05e79934dcb3d228fc',
17 'info_dict': {
18 'id': '53662',
19 'display_id': 'The-Next--Best-West',
20 'ext': 'mp4',
21 'title': 'The Next, Best West',
22 'description': 'md5:0423cd00833dea1519cf014e9d0903b1',
ec85ded8 23 'thumbnail': r're:^https?://.*\.jpg$',
a50a8003
S
24 'creator': 'Coldstream Creative',
25 'duration': 2203,
26 'view_count': int,
27 }
28 }, {
29 'url': 'http://www.cultureunplugged.com/documentary/watch-online/play/53662',
30 'only_matching': True,
31 }]
32
33 def _real_extract(self, url):
5ad28e7f 34 mobj = self._match_valid_url(url)
a50a8003
S
35 video_id = mobj.group('id')
36 display_id = mobj.group('display_id') or video_id
37
e25586e4
RA
38 # request setClientTimezone.php to get PHPSESSID cookie which is need to get valid json data in the next request
39 self._request_webpage(HEADRequest(
40 'http://www.cultureunplugged.com/setClientTimezone.php?timeOffset=%d' % -(time.timezone / 3600)), display_id)
a50a8003
S
41 movie_data = self._download_json(
42 'http://www.cultureunplugged.com/movie-data/cu-%s.json' % video_id, display_id)
43
44 video_url = movie_data['url']
45 title = movie_data['title']
46
47 description = movie_data.get('synopsis')
48 creator = movie_data.get('producer')
49 duration = int_or_none(movie_data.get('duration'))
50 view_count = int_or_none(movie_data.get('views'))
51
52 thumbnails = [{
53 'url': movie_data['%s_thumb' % size],
54 'id': size,
55 'preference': preference,
56 } for preference, size in enumerate((
57 'small', 'large')) if movie_data.get('%s_thumb' % size)]
58
59 return {
60 'id': video_id,
61 'display_id': display_id,
62 'url': video_url,
63 'title': title,
64 'description': description,
65 'creator': creator,
66 'duration': duration,
67 'view_count': view_count,
68 'thumbnails': thumbnails,
69 }