2 from __future__ import unicode_literals
4 from .common import InfoExtractor
5 from ..compat import compat_urlparse
13 class Vbox7IE(InfoExtractor):
14 _VALID_URL = r'https?://(?:www\.)?vbox7\.com/play:(?P<id>[^/]+)'
16 'url': 'http://vbox7.com/play:249bb972c2',
17 'md5': '99f65c0c9ef9b682b97313e052734c3f',
21 'title': 'Смях! Чудо - чист за секунди - Скрита камера',
25 def _real_extract(self, url):
26 video_id = self._match_id(url)
28 # need to get the page 3 times for the correct jsSecretToken cookie
29 # which is necessary for the correct title
31 redirect_page = self._download_webpage(url, video_id)
32 session_id_url = self._search_regex(
33 r'var\s*url\s*=\s*\'([^\']+)\';', redirect_page,
35 self._download_webpage(
36 compat_urlparse.urljoin(url, session_id_url), video_id,
42 webpage = self._download_webpage(url, video_id,
43 'Downloading redirect page')
45 title = self._html_search_regex(r'<title>(.*)</title>',
46 webpage, 'title').split('/')[0].strip()
48 info_url = 'http://vbox7.com/play/magare.do'
49 data = urlencode_postdata({'as3': '1', 'vid': video_id})
50 info_request = sanitized_Request(info_url, data)
51 info_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
52 info_response = self._download_webpage(info_request, video_id, 'Downloading info webpage')
53 if info_response is None:
54 raise ExtractorError('Unable to extract the media url')
55 (final_url, thumbnail_url) = map(lambda x: x.split('=')[1], info_response.split('&'))
61 'thumbnail': thumbnail_url,