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.

55 lines
2.0 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. compat_urllib_parse,
  7. compat_urllib_request,
  8. ExtractorError,
  9. )
  10. class Vbox7IE(InfoExtractor):
  11. _VALID_URL = r'http://(www\.)?vbox7\.com/play:(?P<id>[^/]+)'
  12. _TEST = {
  13. 'url': 'http://vbox7.com/play:249bb972c2',
  14. 'md5': '99f65c0c9ef9b682b97313e052734c3f',
  15. 'info_dict': {
  16. 'id': '249bb972c2',
  17. 'ext': 'mp4',
  18. 'title': 'Смях! Чудо - чист за секунди - Скрита камера',
  19. },
  20. }
  21. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. video_id = mobj.group('id')
  24. redirect_page, urlh = self._download_webpage_handle(url, video_id)
  25. new_location = self._search_regex(r'window\.location = \'(.*)\';',
  26. redirect_page, 'redirect location')
  27. redirect_url = urlh.geturl() + new_location
  28. webpage = self._download_webpage(redirect_url, video_id,
  29. 'Downloading redirect page')
  30. title = self._html_search_regex(r'<title>(.*)</title>',
  31. webpage, 'title').split('/')[0].strip()
  32. info_url = "http://vbox7.com/play/magare.do"
  33. data = compat_urllib_parse.urlencode({'as3': '1', 'vid': video_id})
  34. info_request = compat_urllib_request.Request(info_url, data)
  35. info_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
  36. info_response = self._download_webpage(info_request, video_id, 'Downloading info webpage')
  37. if info_response is None:
  38. raise ExtractorError('Unable to extract the media url')
  39. (final_url, thumbnail_url) = map(lambda x: x.split('=')[1], info_response.split('&'))
  40. return {
  41. 'id': video_id,
  42. 'url': final_url,
  43. 'title': title,
  44. 'thumbnail': thumbnail_url,
  45. }