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
1.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. float_or_none,
  7. )
  8. class VzaarIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:(?:www|view)\.)?vzaar\.com/(?:videos/)?(?P<id>\d+)'
  10. _TESTS = [{
  11. 'url': 'https://vzaar.com/videos/1152805',
  12. 'md5': 'bde5ddfeb104a6c56a93a06b04901dbf',
  13. 'info_dict': {
  14. 'id': '1152805',
  15. 'ext': 'mp4',
  16. 'title': 'sample video (public)',
  17. },
  18. }, {
  19. 'url': 'https://view.vzaar.com/27272/player',
  20. 'md5': '3b50012ac9bbce7f445550d54e0508f2',
  21. 'info_dict': {
  22. 'id': '27272',
  23. 'ext': 'mp3',
  24. 'title': 'MP3',
  25. },
  26. }]
  27. def _real_extract(self, url):
  28. video_id = self._match_id(url)
  29. video_data = self._download_json(
  30. 'http://view.vzaar.com/v2/%s/video' % video_id, video_id)
  31. source_url = video_data['sourceUrl']
  32. info = {
  33. 'id': video_id,
  34. 'title': video_data['videoTitle'],
  35. 'url': source_url,
  36. 'thumbnail': self._proto_relative_url(video_data.get('poster')),
  37. 'duration': float_or_none(video_data.get('videoDuration')),
  38. }
  39. if 'audio' in source_url:
  40. info.update({
  41. 'vcodec': 'none',
  42. 'ext': 'mp3',
  43. })
  44. else:
  45. info.update({
  46. 'width': int_or_none(video_data.get('width')),
  47. 'height': int_or_none(video_data.get('height')),
  48. 'ext': 'mp4',
  49. })
  50. return info