3 from .common
import InfoExtractor
12 class Vbox7IE(InfoExtractor
):
13 """Information Extractor for Vbox7"""
14 _VALID_URL
= r
'(?:http://)?(?:www\.)?vbox7\.com/play:([^/]+)'
16 def _real_extract(self
,url
):
17 mobj
= re
.match(self
._VALID
_URL
, url
)
19 raise ExtractorError(u
'Invalid URL: %s' % url
)
20 video_id
= mobj
.group(1)
22 redirect_page
, urlh
= self
._download
_webpage
_handle
(url
, video_id
)
23 new_location
= self
._search
_regex
(r
'window\.location = \'(.*)\';', redirect_page, u'redirect location
')
24 redirect_url = urlh.geturl() + new_location
25 webpage = self._download_webpage(redirect_url, video_id, u'Downloading redirect page
')
27 title = self._html_search_regex(r'<title
>(.*)</title
>',
28 webpage, u'title
').split('/')[0].strip()
31 info_url = "http://vbox7.com/play/magare.do"
32 data = compat_urllib_parse.urlencode({'as3':'1','vid':video_id})
33 info_request = compat_urllib_request.Request(info_url, data)
34 info_request.add_header('Content
-Type
', 'application
/x
-www
-form
-urlencoded
')
35 info_response = self._download_webpage(info_request, video_id, u'Downloading info webpage
')
36 if info_response is None:
37 raise ExtractorError(u'Unable to extract the media url
')
38 (final_url, thumbnail_url) = map(lambda x: x.split('=')[1], info_response.split('&'))
45 'thumbnail
': thumbnail_url,