summaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/chilloutzone.py
blob: ac4252f1b4696e680173c1460568d066a8f350f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import base64

from .common import InfoExtractor
from ..utils import (
    clean_html,
    int_or_none,
    traverse_obj,
)


class ChilloutzoneIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?chilloutzone\.net/video/(?P<id>[\w-]+)\.html'
    _TESTS = [{
        'url': 'https://www.chilloutzone.net/video/enemene-meck-alle-katzen-weg.html',
        'md5': 'a76f3457e813ea0037e5244f509e66d1',
        'info_dict': {
            'id': 'enemene-meck-alle-katzen-weg',
            'ext': 'mp4',
            'title': 'Enemene Meck - Alle Katzen weg',
            'description': 'Ist das der Umkehrschluss des Niesenden Panda-Babys?',
            'duration': 24,
        },
    }, {
        'note': 'Video hosted at YouTube',
        'url': 'https://www.chilloutzone.net/video/eine-sekunde-bevor.html',
        'info_dict': {
            'id': '1YVQaAgHyRU',
            'ext': 'mp4',
            'title': '16 Photos Taken 1 Second Before Disaster',
            'description': 'md5:58a8fcf6a459fe0a08f54140f0ad1814',
            'uploader': 'BuzzFeedVideo',
            'uploader_id': '@BuzzFeedVideo',
            'upload_date': '20131105',
            'availability': 'public',
            'thumbnail': 'https://i.ytimg.com/vi/1YVQaAgHyRU/maxresdefault.jpg',
            'tags': 'count:41',
            'like_count': int,
            'playable_in_embed': True,
            'channel_url': 'https://www.youtube.com/channel/UCpko_-a4wgz2u_DgDgd9fqA',
            'chapters': 'count:6',
            'live_status': 'not_live',
            'view_count': int,
            'categories': ['Entertainment'],
            'age_limit': 0,
            'channel_id': 'UCpko_-a4wgz2u_DgDgd9fqA',
            'duration': 100,
            'uploader_url': 'http://www.youtube.com/@BuzzFeedVideo',
            'channel_follower_count': int,
            'channel': 'BuzzFeedVideo',
        },
    }, {
        'url': 'https://www.chilloutzone.net/video/icon-blending.html',
        'md5': '2f9d6850ec567b24f0f4fa143b9aa2f9',
        'info_dict': {
            'id': 'LLNkHpSjBfc',
            'ext': 'mp4',
            'title': 'The Sunday Times   Making of Icons',
            'description': 'md5:b9259fcf63a1669e42001e5db677f02a',
            'uploader': 'MadFoxUA',
            'uploader_id': '@MadFoxUA',
            'upload_date': '20140204',
            'channel_id': 'UCSZa9Y6-Vl7c11kWMcbAfCw',
            'channel_url': 'https://www.youtube.com/channel/UCSZa9Y6-Vl7c11kWMcbAfCw',
            'comment_count': int,
            'uploader_url': 'http://www.youtube.com/@MadFoxUA',
            'duration': 66,
            'live_status': 'not_live',
            'channel_follower_count': int,
            'playable_in_embed': True,
            'view_count': int,
            'like_count': int,
            'thumbnail': 'https://i.ytimg.com/vi/LLNkHpSjBfc/maxresdefault.jpg',
            'categories': ['Comedy'],
            'availability': 'public',
            'tags': [],
            'channel': 'MadFoxUA',
            'age_limit': 0,
        },
    }, {
        'url': 'https://www.chilloutzone.net/video/ordentlich-abgeschuettelt.html',
        'info_dict': {
            'id': 'ordentlich-abgeschuettelt',
            'ext': 'mp4',
            'title': 'Ordentlich abgeschüttelt',
            'description': 'md5:d41541966b75d3d1e8ea77a94ea0d329',
            'duration': 18,
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        b64_data = self._html_search_regex(
            r'var cozVidData\s*=\s*"([^"]+)"', webpage, 'video data')
        info = self._parse_json(base64.b64decode(b64_data).decode(), video_id)

        video_url = info.get('mediaUrl')
        native_platform = info.get('nativePlatform')

        if native_platform and info.get('sourcePriority') == 'native':
            native_video_id = info['nativeVideoId']
            if native_platform == 'youtube':
                return self.url_result(native_video_id, 'Youtube')
            elif native_platform == 'vimeo':
                return self.url_result(f'https://vimeo.com/{native_video_id}', 'Vimeo')

        elif not video_url:
            # Possibly a standard youtube embed?
            # TODO: Investigate if site still does this (there are no tests for it)
            return self.url_result(url, 'Generic')

        return {
            'id': video_id,
            'url': video_url,
            'ext': 'mp4',
            **traverse_obj(info, {
                'title': 'title',
                'description': ('description', {clean_html}),
                'duration': ('videoLength', {int_or_none}),
                'width': ('videoWidth', {int_or_none}),
                'height': ('videoHeight', {int_or_none}),
            }),
        }