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.

93 lines
3.3 KiB

  1. from __future__ import unicode_literals
  2. import json
  3. from .common import InfoExtractor
  4. from ..utils import float_or_none
  5. class AzubuIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?azubu\.tv/[^/]+#!/play/(?P<id>\d+)'
  7. _TESTS = [
  8. {
  9. 'url': 'http://www.azubu.tv/GSL#!/play/15575/2014-hot6-cup-last-big-match-ro8-day-1',
  10. 'md5': 'a88b42fcf844f29ad6035054bd9ecaf4',
  11. 'info_dict': {
  12. 'id': '15575',
  13. 'ext': 'mp4',
  14. 'title': '2014 HOT6 CUP LAST BIG MATCH Ro8 Day 1',
  15. 'description': 'md5:d06bdea27b8cc4388a90ad35b5c66c01',
  16. 'thumbnail': 're:^https?://.*\.jpe?g',
  17. 'timestamp': 1417523507.334,
  18. 'upload_date': '20141202',
  19. 'duration': 9988.7,
  20. 'uploader': 'GSL',
  21. 'uploader_id': 414310,
  22. 'view_count': int,
  23. },
  24. },
  25. {
  26. 'url': 'http://www.azubu.tv/FnaticTV#!/play/9344/-fnatic-at-worlds-2014:-toyz---%22i-love-rekkles,-he-has-amazing-mechanics%22-',
  27. 'md5': 'b72a871fe1d9f70bd7673769cdb3b925',
  28. 'info_dict': {
  29. 'id': '9344',
  30. 'ext': 'mp4',
  31. 'title': 'Fnatic at Worlds 2014: Toyz - "I love Rekkles, he has amazing mechanics"',
  32. 'description': 'md5:4a649737b5f6c8b5c5be543e88dc62af',
  33. 'thumbnail': 're:^https?://.*\.jpe?g',
  34. 'timestamp': 1410530893.320,
  35. 'upload_date': '20140912',
  36. 'duration': 172.385,
  37. 'uploader': 'FnaticTV',
  38. 'uploader_id': 272749,
  39. 'view_count': int,
  40. },
  41. },
  42. ]
  43. def _real_extract(self, url):
  44. video_id = self._match_id(url)
  45. data = self._download_json(
  46. 'http://www.azubu.tv/api/video/%s' % video_id, video_id)['data']
  47. title = data['title'].strip()
  48. description = data['description']
  49. thumbnail = data['thumbnail']
  50. view_count = data['view_count']
  51. uploader = data['user']['username']
  52. uploader_id = data['user']['id']
  53. stream_params = json.loads(data['stream_params'])
  54. timestamp = float_or_none(stream_params['creationDate'], 1000)
  55. duration = float_or_none(stream_params['length'], 1000)
  56. renditions = stream_params.get('renditions') or []
  57. video = stream_params.get('FLVFullLength') or stream_params.get('videoFullLength')
  58. if video:
  59. renditions.append(video)
  60. formats = [{
  61. 'url': fmt['url'],
  62. 'width': fmt['frameWidth'],
  63. 'height': fmt['frameHeight'],
  64. 'vbr': float_or_none(fmt['encodingRate'], 1000),
  65. 'filesize': fmt['size'],
  66. 'vcodec': fmt['videoCodec'],
  67. 'container': fmt['videoContainer'],
  68. } for fmt in renditions if fmt['url']]
  69. self._sort_formats(formats)
  70. return {
  71. 'id': video_id,
  72. 'title': title,
  73. 'description': description,
  74. 'thumbnail': thumbnail,
  75. 'timestamp': timestamp,
  76. 'duration': duration,
  77. 'uploader': uploader,
  78. 'uploader_id': uploader_id,
  79. 'view_count': view_count,
  80. 'formats': formats,
  81. }