vbox7.py 3.1 KB

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