]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vidzi.py
3c78fb3d5a071a6f49dec7467e620c0b8a01ded9
[youtubedl] / youtube_dl / extractor / vidzi.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .jwplatform import JWPlatformBaseIE
5 from ..utils import (
6 decode_packed_codes,
7 js_to_json,
8 )
9
10
11 class VidziIE(JWPlatformBaseIE):
12 _VALID_URL = r'https?://(?:www\.)?vidzi\.tv/(?P<id>\w+)'
13 _TEST = {
14 'url': 'http://vidzi.tv/cghql9yq6emu.html',
15 'md5': '4f16c71ca0c8c8635ab6932b5f3f1660',
16 'info_dict': {
17 'id': 'cghql9yq6emu',
18 'ext': 'mp4',
19 'title': 'youtube-dl test video 1\\\\2\'3/4<5\\\\6ä7↭',
20 },
21 'params': {
22 # m3u8 download
23 'skip_download': True,
24 },
25 }
26
27 def _real_extract(self, url):
28 video_id = self._match_id(url)
29
30 webpage = self._download_webpage(url, video_id)
31 title = self._html_search_regex(
32 r'(?s)<h2 class="video-title">(.*?)</h2>', webpage, 'title')
33
34 code = decode_packed_codes(webpage).replace('\\\'', '\'')
35 jwplayer_data = self._parse_json(
36 self._search_regex(r'setup\(([^)]+)\)', code, 'jwplayer data'),
37 video_id, transform_source=js_to_json)
38
39 info_dict = self._parse_jwplayer_data(jwplayer_data, video_id, require_title=False)
40 info_dict['title'] = title
41
42 return info_dict