]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/vidzi.py
[utils] Expose PACKED_CODES_RE
[yt-dlp.git] / youtube_dl / extractor / vidzi.py
CommitLineData
5f6a1245 1# coding: utf-8
018e8355
PH
2from __future__ import unicode_literals
3
8f4a2124
YCH
4from .jwplatform import JWPlatformBaseIE
5from ..utils import (
efbd6fb8 6 decode_packed_codes,
8f4a2124
YCH
7 js_to_json,
8)
018e8355 9
8f4a2124
YCH
10
11class VidziIE(JWPlatformBaseIE):
5c4dcf81
S
12 _VALID_URL = r'https?://(?:www\.)?vidzi\.tv/(?:embed-)?(?P<id>[0-9a-zA-Z]+)'
13 _TESTS = [{
2c26df76
PH
14 'url': 'http://vidzi.tv/cghql9yq6emu.html',
15 'md5': '4f16c71ca0c8c8635ab6932b5f3f1660',
95ee8442 16 'info_dict': {
2c26df76 17 'id': 'cghql9yq6emu',
95ee8442 18 'ext': 'mp4',
2c26df76 19 'title': 'youtube-dl test video 1\\\\2\'3/4<5\\\\6ä7↭',
bd93a12e
YCH
20 },
21 'params': {
22 # m3u8 download
23 'skip_download': True,
95ee8442 24 },
5c4dcf81
S
25 }, {
26 'url': 'http://vidzi.tv/embed-4z2yb0rzphe9-600x338.html',
27 'skip_download': True,
28 }]
95ee8442 29
30 def _real_extract(self, url):
018e8355 31 video_id = self._match_id(url)
5f6a1245 32
5c4dcf81
S
33 webpage = self._download_webpage(
34 'http://vidzi.tv/%s' % video_id, video_id)
018e8355 35 title = self._html_search_regex(
2c26df76 36 r'(?s)<h2 class="video-title">(.*?)</h2>', webpage, 'title')
5f6a1245 37
efbd6fb8 38 code = decode_packed_codes(webpage).replace('\\\'', '\'')
8f4a2124
YCH
39 jwplayer_data = self._parse_json(
40 self._search_regex(r'setup\(([^)]+)\)', code, 'jwplayer data'),
41 video_id, transform_source=js_to_json)
42
43 info_dict = self._parse_jwplayer_data(jwplayer_data, video_id, require_title=False)
44 info_dict['title'] = title
45
46 return info_dict