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.

74 lines
2.5 KiB

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 urlencode_postdata
  6. class Vbox7IE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:www\.)?vbox7\.com/(?:play:|emb/external\.php\?.*?\bvid=)(?P<id>[\da-fA-F]+)'
  8. _TESTS = [{
  9. 'url': 'http://vbox7.com/play:0946fff23c',
  10. 'md5': 'a60f9ab3a3a2f013ef9a967d5f7be5bf',
  11. 'info_dict': {
  12. 'id': '0946fff23c',
  13. 'ext': 'mp4',
  14. 'title': 'Борисов: Притеснен съм за бъдещето на България',
  15. },
  16. }, {
  17. 'url': 'http://vbox7.com/play:249bb972c2',
  18. 'md5': '99f65c0c9ef9b682b97313e052734c3f',
  19. 'info_dict': {
  20. 'id': '249bb972c2',
  21. 'ext': 'mp4',
  22. 'title': 'Смях! Чудо - чист за секунди - Скрита камера',
  23. },
  24. 'skip': 'georestricted',
  25. }, {
  26. 'url': 'http://vbox7.com/emb/external.php?vid=a240d20f9c&autoplay=1',
  27. 'only_matching': True,
  28. }]
  29. @staticmethod
  30. def _extract_url(webpage):
  31. mobj = re.search(
  32. '<iframe[^>]+src=(?P<q>["\'])(?P<url>(?:https?:)?//vbox7\.com/emb/external\.php.+?)(?P=q)',
  33. webpage)
  34. if mobj:
  35. return mobj.group('url')
  36. def _real_extract(self, url):
  37. video_id = self._match_id(url)
  38. webpage = self._download_webpage(
  39. 'http://vbox7.com/play:%s' % video_id, video_id)
  40. title = self._html_search_regex(
  41. r'<title>(.+?)</title>', webpage, 'title').split('/')[0].strip()
  42. video_url = self._search_regex(
  43. r'src\s*:\s*(["\'])(?P<url>.+?.mp4.*?)\1',
  44. webpage, 'video url', default=None, group='url')
  45. thumbnail_url = self._og_search_thumbnail(webpage)
  46. if not video_url:
  47. info_response = self._download_webpage(
  48. 'http://vbox7.com/play/magare.do', video_id,
  49. 'Downloading info webpage',
  50. data=urlencode_postdata({'as3': '1', 'vid': video_id}),
  51. headers={'Content-Type': 'application/x-www-form-urlencoded'})
  52. final_url, thumbnail_url = map(
  53. lambda x: x.split('=')[1], info_response.split('&'))
  54. if '/na.mp4' in video_url:
  55. self.raise_geo_restricted()
  56. return {
  57. 'id': video_id,
  58. 'url': self._proto_relative_url(video_url, 'http:'),
  59. 'title': title,
  60. 'thumbnail': thumbnail_url,
  61. }