]>
Commit | Line | Data |
---|---|---|
4a9540b6 PH |
1 | from __future__ import unicode_literals |
2 | ||
46a073bf | 3 | import re |
46a073bf AS |
4 | import json |
5 | ||
6 | from .common import InfoExtractor | |
5113b691 | 7 | from .youtube import YoutubeIE |
cf282071 | 8 | from ..compat import compat_b64decode |
d914d9d1 PH |
9 | from ..utils import ( |
10 | clean_html, | |
11 | ExtractorError | |
12 | ) | |
46a073bf | 13 | |
46a073bf AS |
14 | |
15 | class ChilloutzoneIE(InfoExtractor): | |
4a9540b6 | 16 | _VALID_URL = r'https?://(?:www\.)?chilloutzone\.net/video/(?P<id>[\w|-]+)\.html' |
8bc6c8e3 | 17 | _TESTS = [{ |
cd8662de AS |
18 | 'url': 'http://www.chilloutzone.net/video/enemene-meck-alle-katzen-weg.html', |
19 | 'md5': 'a76f3457e813ea0037e5244f509e66d1', | |
20 | 'info_dict': { | |
21 | 'id': 'enemene-meck-alle-katzen-weg', | |
22 | 'ext': 'mp4', | |
23 | 'title': 'Enemene Meck - Alle Katzen weg', | |
4a9540b6 | 24 | 'description': 'Ist das der Umkehrschluss des Niesenden Panda-Babys?', |
cd8662de | 25 | }, |
8bc6c8e3 PH |
26 | }, { |
27 | 'note': 'Video hosted at YouTube', | |
28 | 'url': 'http://www.chilloutzone.net/video/eine-sekunde-bevor.html', | |
29 | 'info_dict': { | |
30 | 'id': '1YVQaAgHyRU', | |
31 | 'ext': 'mp4', | |
32 | 'title': '16 Photos Taken 1 Second Before Disaster', | |
33 | 'description': 'md5:58a8fcf6a459fe0a08f54140f0ad1814', | |
34 | 'uploader': 'BuzzFeedVideo', | |
35 | 'uploader_id': 'BuzzFeedVideo', | |
36 | 'upload_date': '20131105', | |
37 | }, | |
38 | }, { | |
39 | 'note': 'Video hosted at Vimeo', | |
40 | 'url': 'http://www.chilloutzone.net/video/icon-blending.html', | |
41 | 'md5': '2645c678b8dc4fefcc0e1b60db18dac1', | |
42 | 'info_dict': { | |
43 | 'id': '85523671', | |
44 | 'ext': 'mp4', | |
45 | 'title': 'The Sunday Times - Icons', | |
3a36d378 | 46 | 'description': 're:(?s)^Watch the making of - makingoficons.com.{300,}', |
8bc6c8e3 PH |
47 | 'uploader': 'Us', |
48 | 'uploader_id': 'usfilms', | |
49 | 'upload_date': '20140131' | |
50 | }, | |
51 | }] | |
46a073bf AS |
52 | |
53 | def _real_extract(self, url): | |
54 | mobj = re.match(self._VALID_URL, url) | |
cd8662de AS |
55 | video_id = mobj.group('id') |
56 | ||
4a9540b6 | 57 | webpage = self._download_webpage(url, video_id) |
cd8662de | 58 | |
4a9540b6 PH |
59 | base64_video_info = self._html_search_regex( |
60 | r'var cozVidData = "(.+?)";', webpage, 'video data') | |
cf282071 | 61 | decoded_video_info = compat_b64decode(base64_video_info).decode('utf-8') |
cd8662de | 62 | video_info_dict = json.loads(decoded_video_info) |
4a9540b6 | 63 | |
cd8662de | 64 | # get video information from dict |
4a9540b6 PH |
65 | video_url = video_info_dict['mediaUrl'] |
66 | description = clean_html(video_info_dict.get('description')) | |
cd8662de AS |
67 | title = video_info_dict['title'] |
68 | native_platform = video_info_dict['nativePlatform'] | |
69 | native_video_id = video_info_dict['nativeVideoId'] | |
70 | source_priority = video_info_dict['sourcePriority'] | |
71 | ||
cd8662de | 72 | # If nativePlatform is None a fallback mechanism is used (i.e. youtube embed) |
4a9540b6 | 73 | if native_platform is None: |
5113b691 S |
74 | youtube_url = YoutubeIE._extract_url(webpage) |
75 | if youtube_url: | |
76 | return self.url_result(youtube_url, ie=YoutubeIE.ie_key()) | |
cd8662de AS |
77 | |
78 | # Non Fallback: Decide to use native source (e.g. youtube or vimeo) or | |
79 | # the own CDN | |
80 | if source_priority == 'native': | |
81 | if native_platform == 'youtube': | |
c1e672d1 | 82 | return self.url_result(native_video_id, ie='Youtube') |
46a073bf | 83 | if native_platform == 'vimeo': |
4a9540b6 PH |
84 | return self.url_result( |
85 | 'http://vimeo.com/' + native_video_id, ie='Vimeo') | |
46a073bf | 86 | |
4a9540b6 PH |
87 | if not video_url: |
88 | raise ExtractorError('No video found') | |
46a073bf | 89 | |
4a9540b6 PH |
90 | return { |
91 | 'id': video_id, | |
92 | 'url': video_url, | |
93 | 'ext': 'mp4', | |
94 | 'title': title, | |
cd8662de | 95 | 'description': description, |
4a9540b6 | 96 | } |