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.

142 lines
5.5 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. compat_str,
  7. )
  8. class VubeIE(InfoExtractor):
  9. IE_NAME = 'vube'
  10. IE_DESC = 'Vube.com'
  11. _VALID_URL = r'http://vube\.com/(?:[^/]+/)+(?P<id>[\da-zA-Z]{10})\b'
  12. _TESTS = [
  13. {
  14. 'url': 'http://vube.com/Chiara+Grispo+Video+Channel/YL2qNPkqon',
  15. 'md5': 'db7aba89d4603dadd627e9d1973946fe',
  16. 'info_dict': {
  17. 'id': 'YL2qNPkqon',
  18. 'ext': 'mp4',
  19. 'title': 'Chiara Grispo - Price Tag by Jessie J',
  20. 'description': 'md5:8ea652a1f36818352428cb5134933313',
  21. 'thumbnail': 're:^http://frame\.thestaticvube\.com/snap/[0-9x]+/102e7e63057-5ebc-4f5c-4065-6ce4ebde131f\.jpg$',
  22. 'uploader': 'Chiara.Grispo',
  23. 'timestamp': 1388743358,
  24. 'upload_date': '20140103',
  25. 'duration': 170.56,
  26. 'like_count': int,
  27. 'dislike_count': int,
  28. 'comment_count': int,
  29. 'categories': ['pop', 'music', 'cover', 'singing', 'jessie j', 'price tag', 'chiara grispo'],
  30. }
  31. },
  32. {
  33. 'url': 'http://vube.com/SerainaMusic/my-7-year-old-sister-and-i-singing-alive-by-krewella/UeBhTudbfS?t=s&n=1',
  34. 'md5': '5d4a52492d76f72712117ce6b0d98d08',
  35. 'info_dict': {
  36. 'id': 'UeBhTudbfS',
  37. 'ext': 'mp4',
  38. 'title': 'My 7 year old Sister and I singing "Alive" by Krewella',
  39. 'description': 'md5:40bcacb97796339f1690642c21d56f4a',
  40. 'thumbnail': 're:^http://frame\.thestaticvube\.com/snap/[0-9x]+/102265d5a9f-0f17-4f6b-5753-adf08484ee1e\.jpg$',
  41. 'uploader': 'Seraina',
  42. 'timestamp': 1396492438,
  43. 'upload_date': '20140403',
  44. 'duration': 240.107,
  45. 'like_count': int,
  46. 'dislike_count': int,
  47. 'comment_count': int,
  48. 'categories': ['seraina', 'jessica', 'krewella', 'alive'],
  49. }
  50. }, {
  51. 'url': 'http://vube.com/vote/Siren+Gene/0nmsMY5vEq?n=2&t=s',
  52. 'md5': '0584fc13b50f887127d9d1007589d27f',
  53. 'info_dict': {
  54. 'id': '0nmsMY5vEq',
  55. 'ext': 'mp4',
  56. 'title': 'Frozen - Let It Go Cover by Siren Gene',
  57. 'description': 'My rendition of "Let It Go" originally sung by Idina Menzel.',
  58. 'thumbnail': 're:^http://frame\.thestaticvube\.com/snap/[0-9x]+/10283ab622a-86c9-4681-51f2-30d1f65774af\.jpg$',
  59. 'uploader': 'Siren',
  60. 'timestamp': 1395448018,
  61. 'upload_date': '20140322',
  62. 'duration': 221.788,
  63. 'like_count': int,
  64. 'dislike_count': int,
  65. 'comment_count': int,
  66. 'categories': ['let it go', 'cover', 'idina menzel', 'frozen', 'singing', 'disney', 'siren gene'],
  67. }
  68. }
  69. ]
  70. def _real_extract(self, url):
  71. mobj = re.match(self._VALID_URL, url)
  72. video_id = mobj.group('id')
  73. video = self._download_json(
  74. 'http://vube.com/t-api/v1/video/%s' % video_id, video_id, 'Downloading video JSON')
  75. public_id = video['public_id']
  76. formats = []
  77. for media in video['media'].get('video', []) + video['media'].get('audio', []):
  78. if media['transcoding_status'] != 'processed':
  79. continue
  80. fmt = {
  81. 'url': 'http://video.thestaticvube.com/video/%s/%s.mp4' % (media['media_resolution_id'], public_id),
  82. 'abr': int(media['audio_bitrate']),
  83. 'format_id': compat_str(media['media_resolution_id']),
  84. }
  85. vbr = int(media['video_bitrate'])
  86. if vbr:
  87. fmt.update({
  88. 'vbr': vbr,
  89. 'height': int(media['height']),
  90. })
  91. formats.append(fmt)
  92. self._sort_formats(formats)
  93. title = video['title']
  94. description = video.get('description')
  95. thumbnail = self._proto_relative_url(video.get('thumbnail_src'), scheme='http:')
  96. uploader = video.get('user_alias') or video.get('channel')
  97. timestamp = int_or_none(video.get('upload_time'))
  98. duration = video['duration']
  99. view_count = video.get('raw_view_count')
  100. like_count = video.get('total_likes')
  101. dislike_count = video.get('total_hates')
  102. comments = video.get('comments')
  103. comment_count = None
  104. if comments is None:
  105. comment_data = self._download_json(
  106. 'http://vube.com/api/video/%s/comment' % video_id,
  107. video_id, 'Downloading video comment JSON', fatal=False)
  108. if comment_data is not None:
  109. comment_count = int_or_none(comment_data.get('total'))
  110. else:
  111. comment_count = len(comments)
  112. categories = [tag['text'] for tag in video['tags']]
  113. return {
  114. 'id': video_id,
  115. 'formats': formats,
  116. 'title': title,
  117. 'description': description,
  118. 'thumbnail': thumbnail,
  119. 'uploader': uploader,
  120. 'timestamp': timestamp,
  121. 'duration': duration,
  122. 'view_count': view_count,
  123. 'like_count': like_count,
  124. 'dislike_count': dislike_count,
  125. 'comment_count': comment_count,
  126. 'categories': categories,
  127. }