You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.7 KiB

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