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.

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