[cleanup] Make more playlist entries lazy (#11763)
[yt-dlp.git] / yt_dlp / extractor / cultureunplugged.py
blobc7ccd27479518a8f81fabc3bfbb5c2ef1335777b
1 from .common import InfoExtractor
2 from ..utils import int_or_none
5 class CultureUnpluggedIE(InfoExtractor):
6 _VALID_URL = r'https?://(?:www\.)?cultureunplugged\.com/documentary/watch-online/play/(?P<id>\d+)(?:/(?P<display_id>[^/]+))?'
7 _TESTS = [{
8 'url': 'http://www.cultureunplugged.com/documentary/watch-online/play/53662/The-Next--Best-West',
9 'md5': 'ac6c093b089f7d05e79934dcb3d228fc',
10 'info_dict': {
11 'id': '53662',
12 'display_id': 'The-Next--Best-West',
13 'ext': 'mp4',
14 'title': 'The Next, Best West',
15 'description': 'md5:0423cd00833dea1519cf014e9d0903b1',
16 'thumbnail': r're:^https?://.*\.jpg$',
17 'creator': 'Coldstream Creative',
18 'duration': 2203,
19 'view_count': int,
21 }, {
22 'url': 'http://www.cultureunplugged.com/documentary/watch-online/play/53662',
23 'only_matching': True,
26 def _real_extract(self, url):
27 mobj = self._match_valid_url(url)
28 video_id = mobj.group('id')
29 display_id = mobj.group('display_id') or video_id
31 movie_data = self._download_json(
32 f'http://www.cultureunplugged.com/movie-data/cu-{video_id}.json', display_id)
34 video_url = movie_data['url']
35 title = movie_data['title']
37 description = movie_data.get('synopsis')
38 creator = movie_data.get('producer')
39 duration = int_or_none(movie_data.get('duration'))
40 view_count = int_or_none(movie_data.get('views'))
42 thumbnails = [{
43 'url': movie_data[f'{size}_thumb'],
44 'id': size,
45 'preference': preference,
46 } for preference, size in enumerate((
47 'small', 'large')) if movie_data.get(f'{size}_thumb')]
49 return {
50 'id': video_id,
51 'display_id': display_id,
52 'url': video_url,
53 'title': title,
54 'description': description,
55 'creator': creator,
56 'duration': duration,
57 'view_count': view_count,
58 'thumbnails': thumbnails,