[ie/twitter:spaces] Support video spaces (#10789)
[yt-dlp3.git] / yt_dlp / extractor / chilloutzone.py
blobac4252f1b4696e680173c1460568d066a8f350f8
1 import base64
3 from .common import InfoExtractor
4 from ..utils import (
5 clean_html,
6 int_or_none,
7 traverse_obj,
11 class ChilloutzoneIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.)?chilloutzone\.net/video/(?P<id>[\w-]+)\.html'
13 _TESTS = [{
14 'url': 'https://www.chilloutzone.net/video/enemene-meck-alle-katzen-weg.html',
15 'md5': 'a76f3457e813ea0037e5244f509e66d1',
16 'info_dict': {
17 'id': 'enemene-meck-alle-katzen-weg',
18 'ext': 'mp4',
19 'title': 'Enemene Meck - Alle Katzen weg',
20 'description': 'Ist das der Umkehrschluss des Niesenden Panda-Babys?',
21 'duration': 24,
23 }, {
24 'note': 'Video hosted at YouTube',
25 'url': 'https://www.chilloutzone.net/video/eine-sekunde-bevor.html',
26 'info_dict': {
27 'id': '1YVQaAgHyRU',
28 'ext': 'mp4',
29 'title': '16 Photos Taken 1 Second Before Disaster',
30 'description': 'md5:58a8fcf6a459fe0a08f54140f0ad1814',
31 'uploader': 'BuzzFeedVideo',
32 'uploader_id': '@BuzzFeedVideo',
33 'upload_date': '20131105',
34 'availability': 'public',
35 'thumbnail': 'https://i.ytimg.com/vi/1YVQaAgHyRU/maxresdefault.jpg',
36 'tags': 'count:41',
37 'like_count': int,
38 'playable_in_embed': True,
39 'channel_url': 'https://www.youtube.com/channel/UCpko_-a4wgz2u_DgDgd9fqA',
40 'chapters': 'count:6',
41 'live_status': 'not_live',
42 'view_count': int,
43 'categories': ['Entertainment'],
44 'age_limit': 0,
45 'channel_id': 'UCpko_-a4wgz2u_DgDgd9fqA',
46 'duration': 100,
47 'uploader_url': 'http://www.youtube.com/@BuzzFeedVideo',
48 'channel_follower_count': int,
49 'channel': 'BuzzFeedVideo',
51 }, {
52 'url': 'https://www.chilloutzone.net/video/icon-blending.html',
53 'md5': '2f9d6850ec567b24f0f4fa143b9aa2f9',
54 'info_dict': {
55 'id': 'LLNkHpSjBfc',
56 'ext': 'mp4',
57 'title': 'The Sunday Times Making of Icons',
58 'description': 'md5:b9259fcf63a1669e42001e5db677f02a',
59 'uploader': 'MadFoxUA',
60 'uploader_id': '@MadFoxUA',
61 'upload_date': '20140204',
62 'channel_id': 'UCSZa9Y6-Vl7c11kWMcbAfCw',
63 'channel_url': 'https://www.youtube.com/channel/UCSZa9Y6-Vl7c11kWMcbAfCw',
64 'comment_count': int,
65 'uploader_url': 'http://www.youtube.com/@MadFoxUA',
66 'duration': 66,
67 'live_status': 'not_live',
68 'channel_follower_count': int,
69 'playable_in_embed': True,
70 'view_count': int,
71 'like_count': int,
72 'thumbnail': 'https://i.ytimg.com/vi/LLNkHpSjBfc/maxresdefault.jpg',
73 'categories': ['Comedy'],
74 'availability': 'public',
75 'tags': [],
76 'channel': 'MadFoxUA',
77 'age_limit': 0,
79 }, {
80 'url': 'https://www.chilloutzone.net/video/ordentlich-abgeschuettelt.html',
81 'info_dict': {
82 'id': 'ordentlich-abgeschuettelt',
83 'ext': 'mp4',
84 'title': 'Ordentlich abgeschüttelt',
85 'description': 'md5:d41541966b75d3d1e8ea77a94ea0d329',
86 'duration': 18,
90 def _real_extract(self, url):
91 video_id = self._match_id(url)
92 webpage = self._download_webpage(url, video_id)
93 b64_data = self._html_search_regex(
94 r'var cozVidData\s*=\s*"([^"]+)"', webpage, 'video data')
95 info = self._parse_json(base64.b64decode(b64_data).decode(), video_id)
97 video_url = info.get('mediaUrl')
98 native_platform = info.get('nativePlatform')
100 if native_platform and info.get('sourcePriority') == 'native':
101 native_video_id = info['nativeVideoId']
102 if native_platform == 'youtube':
103 return self.url_result(native_video_id, 'Youtube')
104 elif native_platform == 'vimeo':
105 return self.url_result(f'https://vimeo.com/{native_video_id}', 'Vimeo')
107 elif not video_url:
108 # Possibly a standard youtube embed?
109 # TODO: Investigate if site still does this (there are no tests for it)
110 return self.url_result(url, 'Generic')
112 return {
113 'id': video_id,
114 'url': video_url,
115 'ext': 'mp4',
116 **traverse_obj(info, {
117 'title': 'title',
118 'description': ('description', {clean_html}),
119 'duration': ('videoLength', {int_or_none}),
120 'width': ('videoWidth', {int_or_none}),
121 'height': ('videoHeight', {int_or_none}),