2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
  15 class Vbox7IE(InfoExtractor
): 
  16     _VALID_URL 
= r
'http://(www\.)?vbox7\.com/play:(?P<id>[^/]+)' 
  18         'url': 'http://vbox7.com/play:249bb972c2', 
  19         'md5': '99f65c0c9ef9b682b97313e052734c3f', 
  23             'title': 'Смях! Чудо - чист за секунди - Скрита камера', 
  27     def _real_extract(self
, url
): 
  28         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  29         video_id 
= mobj
.group('id') 
  31         redirect_page
, urlh 
= self
._download
_webpage
_handle
(url
, video_id
) 
  32         new_location 
= self
._search
_regex
(r
'window\.location = \'(.*)\';', 
  33             redirect_page, 'redirect location
') 
  34         redirect_url = urlh.geturl() + new_location 
  35         webpage = self._download_webpage(redirect_url, video_id, 
  36             'Downloading redirect page
') 
  38         title = self._html_search_regex(r'<title
>(.*)</title
>', 
  39             webpage, 'title
').split('/')[0].strip() 
  41         info_url = "http://vbox7.com/play/magare.do" 
  42         data = compat_urllib_parse.urlencode({'as3
': '1', 'vid
': video_id}) 
  43         info_request = compat_urllib_request.Request(info_url, data) 
  44         info_request.add_header('Content
-Type
', 'application
/x
-www
-form
-urlencoded
') 
  45         info_response = self._download_webpage(info_request, video_id, 'Downloading info webpage
') 
  46         if info_response is None: 
  47             raise ExtractorError('Unable to extract the media url
') 
  48         (final_url, thumbnail_url) = map(lambda x: x.split('=')[1], info_response.split('&')) 
  54             'thumbnail
': thumbnail_url,