]>
Commit | Line | Data |
---|---|---|
5f6a1245 | 1 | # coding: utf-8 |
018e8355 PH |
2 | from __future__ import unicode_literals |
3 | ||
2b96b06b S |
4 | import re |
5 | ||
a4a554a7 | 6 | from .common import InfoExtractor |
8f4a2124 | 7 | from ..utils import ( |
efbd6fb8 | 8 | decode_packed_codes, |
8f4a2124 | 9 | js_to_json, |
2b96b06b S |
10 | NO_DEFAULT, |
11 | PACKED_CODES_RE, | |
8f4a2124 | 12 | ) |
018e8355 | 13 | |
8f4a2124 | 14 | |
a4a554a7 | 15 | class VidziIE(InfoExtractor): |
135e6a1c | 16 | _VALID_URL = r'https?://(?:www\.)?vidzi\.(?:tv|cc|si|nu)/(?:embed-)?(?P<id>[0-9a-zA-Z]+)' |
5c4dcf81 | 17 | _TESTS = [{ |
2c26df76 PH |
18 | 'url': 'http://vidzi.tv/cghql9yq6emu.html', |
19 | 'md5': '4f16c71ca0c8c8635ab6932b5f3f1660', | |
95ee8442 | 20 | 'info_dict': { |
2c26df76 | 21 | 'id': 'cghql9yq6emu', |
95ee8442 | 22 | 'ext': 'mp4', |
7a5c1cfe | 23 | 'title': 'youtube-dl test video 1\\\\2\'3/4<5\\\\6ä7↭', |
bd93a12e YCH |
24 | }, |
25 | 'params': { | |
26 | # m3u8 download | |
27 | 'skip_download': True, | |
95ee8442 | 28 | }, |
5c4dcf81 S |
29 | }, { |
30 | 'url': 'http://vidzi.tv/embed-4z2yb0rzphe9-600x338.html', | |
7512aa98 | 31 | 'only_matching': True, |
58ad6995 S |
32 | }, { |
33 | 'url': 'http://vidzi.cc/cghql9yq6emu.html', | |
7512aa98 | 34 | 'only_matching': True, |
c01db237 S |
35 | }, { |
36 | 'url': 'https://vidzi.si/rph9gztxj1et.html', | |
37 | 'only_matching': True, | |
135e6a1c S |
38 | }, { |
39 | 'url': 'http://vidzi.nu/cghql9yq6emu.html', | |
40 | 'only_matching': True, | |
5c4dcf81 | 41 | }] |
95ee8442 | 42 | |
43 | def _real_extract(self, url): | |
018e8355 | 44 | video_id = self._match_id(url) |
5f6a1245 | 45 | |
5c4dcf81 S |
46 | webpage = self._download_webpage( |
47 | 'http://vidzi.tv/%s' % video_id, video_id) | |
018e8355 | 48 | title = self._html_search_regex( |
2c26df76 | 49 | r'(?s)<h2 class="video-title">(.*?)</h2>', webpage, 'title') |
5f6a1245 | 50 | |
f7799582 S |
51 | codes = [webpage] |
52 | codes.extend([ | |
53 | decode_packed_codes(mobj.group(0)).replace('\\\'', '\'') | |
54 | for mobj in re.finditer(PACKED_CODES_RE, webpage)]) | |
55 | for num, code in enumerate(codes, 1): | |
2b96b06b S |
56 | jwplayer_data = self._parse_json( |
57 | self._search_regex( | |
58 | r'setup\(([^)]+)\)', code, 'jwplayer data', | |
f7799582 | 59 | default=NO_DEFAULT if num == len(codes) else '{}'), |
81c5df4f U |
60 | video_id, transform_source=lambda s: js_to_json( |
61 | re.sub(r'\s*\+\s*window\[.+?\]', '', s))) | |
2b96b06b S |
62 | if jwplayer_data: |
63 | break | |
8f4a2124 YCH |
64 | |
65 | info_dict = self._parse_jwplayer_data(jwplayer_data, video_id, require_title=False) | |
66 | info_dict['title'] = title | |
67 | ||
68 | return info_dict |