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.

105 lines
3.3 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import ExtractorError
  6. class Vbox7IE(InfoExtractor):
  7. _VALID_URL = r'''(?x)
  8. https?://
  9. (?:[^/]+\.)?vbox7\.com/
  10. (?:
  11. play:|
  12. (?:
  13. emb/external\.php|
  14. player/ext\.swf
  15. )\?.*?\bvid=
  16. )
  17. (?P<id>[\da-fA-F]+)
  18. '''
  19. _GEO_COUNTRIES = ['BG']
  20. _TESTS = [{
  21. 'url': 'http://vbox7.com/play:0946fff23c',
  22. 'md5': 'a60f9ab3a3a2f013ef9a967d5f7be5bf',
  23. 'info_dict': {
  24. 'id': '0946fff23c',
  25. 'ext': 'mp4',
  26. 'title': 'Борисов: Притеснен съм за бъдещето на България',
  27. 'description': 'По думите му е опасно страната ни да бъде обявена за "сигурна"',
  28. 'thumbnail': r're:^https?://.*\.jpg$',
  29. 'timestamp': 1470982814,
  30. 'upload_date': '20160812',
  31. 'uploader': 'zdraveibulgaria',
  32. },
  33. 'params': {
  34. 'proxy': '127.0.0.1:8118',
  35. },
  36. }, {
  37. 'url': 'http://vbox7.com/play:249bb972c2',
  38. 'md5': '99f65c0c9ef9b682b97313e052734c3f',
  39. 'info_dict': {
  40. 'id': '249bb972c2',
  41. 'ext': 'mp4',
  42. 'title': 'Смях! Чудо - чист за секунди - Скрита камера',
  43. },
  44. 'skip': 'georestricted',
  45. }, {
  46. 'url': 'http://vbox7.com/emb/external.php?vid=a240d20f9c&autoplay=1',
  47. 'only_matching': True,
  48. }, {
  49. 'url': 'http://i49.vbox7.com/player/ext.swf?vid=0946fff23c&autoplay=1',
  50. 'only_matching': True,
  51. }]
  52. @staticmethod
  53. def _extract_url(webpage):
  54. mobj = re.search(
  55. r'<iframe[^>]+src=(?P<q>["\'])(?P<url>(?:https?:)?//vbox7\.com/emb/external\.php.+?)(?P=q)',
  56. webpage)
  57. if mobj:
  58. return mobj.group('url')
  59. def _real_extract(self, url):
  60. video_id = self._match_id(url)
  61. response = self._download_json(
  62. 'https://www.vbox7.com/ajax/video/nextvideo.php?vid=%s' % video_id,
  63. video_id)
  64. if 'error' in response:
  65. raise ExtractorError(
  66. '%s said: %s' % (self.IE_NAME, response['error']), expected=True)
  67. video = response['options']
  68. title = video['title']
  69. video_url = video['src']
  70. if '/na.mp4' in video_url:
  71. self.raise_geo_restricted(countries=self._GEO_COUNTRIES)
  72. uploader = video.get('uploader')
  73. webpage = self._download_webpage(
  74. 'http://vbox7.com/play:%s' % video_id, video_id, fatal=None)
  75. info = {}
  76. if webpage:
  77. info = self._search_json_ld(
  78. webpage.replace('"/*@context"', '"@context"'), video_id,
  79. fatal=False)
  80. info.update({
  81. 'id': video_id,
  82. 'title': title,
  83. 'url': video_url,
  84. 'uploader': uploader,
  85. 'thumbnail': self._proto_relative_url(
  86. info.get('thumbnail') or self._og_search_thumbnail(webpage),
  87. 'http:'),
  88. })
  89. return info