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.

169 lines
6.7 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. ExtractorError,
  8. )
  9. class VubeIE(InfoExtractor):
  10. IE_NAME = 'vube'
  11. IE_DESC = 'Vube.com'
  12. _VALID_URL = r'http://vube\.com/(?:[^/]+/)+(?P<id>[\da-zA-Z]{10})\b'
  13. _TESTS = [
  14. {
  15. 'url': 'http://vube.com/trending/William+Wei/Y8NUZ69Tf7?t=s',
  16. 'md5': 'e7aabe1f8f1aa826b9e4735e1f9cee42',
  17. 'info_dict': {
  18. 'id': 'Y8NUZ69Tf7',
  19. 'ext': 'mp4',
  20. 'title': 'Best Drummer Ever [HD]',
  21. 'description': 'md5:2d63c4b277b85c2277761c2cf7337d71',
  22. 'thumbnail': 're:^https?://.*\.jpg',
  23. 'uploader': 'William',
  24. 'timestamp': 1406876915,
  25. 'upload_date': '20140801',
  26. 'duration': 258.051,
  27. 'like_count': int,
  28. 'dislike_count': int,
  29. 'comment_count': int,
  30. 'categories': ['amazing', 'hd', 'best drummer ever', 'william wei', 'bucket drumming', 'street drummer', 'epic street drumming'],
  31. },
  32. }, {
  33. 'url': 'http://vube.com/Chiara+Grispo+Video+Channel/YL2qNPkqon',
  34. 'md5': 'db7aba89d4603dadd627e9d1973946fe',
  35. 'info_dict': {
  36. 'id': 'YL2qNPkqon',
  37. 'ext': 'mp4',
  38. 'title': 'Chiara Grispo - Price Tag by Jessie J',
  39. 'description': 'md5:8ea652a1f36818352428cb5134933313',
  40. 'thumbnail': 're:^http://frame\.thestaticvube\.com/snap/[0-9x]+/102e7e63057-5ebc-4f5c-4065-6ce4ebde131f\.jpg$',
  41. 'uploader': 'Chiara.Grispo',
  42. 'timestamp': 1388743358,
  43. 'upload_date': '20140103',
  44. 'duration': 170.56,
  45. 'like_count': int,
  46. 'dislike_count': int,
  47. 'comment_count': int,
  48. 'categories': ['pop', 'music', 'cover', 'singing', 'jessie j', 'price tag', 'chiara grispo'],
  49. },
  50. 'skip': 'Removed due to DMCA',
  51. },
  52. {
  53. 'url': 'http://vube.com/SerainaMusic/my-7-year-old-sister-and-i-singing-alive-by-krewella/UeBhTudbfS?t=s&n=1',
  54. 'md5': '5d4a52492d76f72712117ce6b0d98d08',
  55. 'info_dict': {
  56. 'id': 'UeBhTudbfS',
  57. 'ext': 'mp4',
  58. 'title': 'My 7 year old Sister and I singing "Alive" by Krewella',
  59. 'description': 'md5:40bcacb97796339f1690642c21d56f4a',
  60. 'thumbnail': 're:^http://frame\.thestaticvube\.com/snap/[0-9x]+/102265d5a9f-0f17-4f6b-5753-adf08484ee1e\.jpg$',
  61. 'uploader': 'Seraina',
  62. 'timestamp': 1396492438,
  63. 'upload_date': '20140403',
  64. 'duration': 240.107,
  65. 'like_count': int,
  66. 'dislike_count': int,
  67. 'comment_count': int,
  68. 'categories': ['seraina', 'jessica', 'krewella', 'alive'],
  69. },
  70. 'skip': 'Removed due to DMCA',
  71. }, {
  72. 'url': 'http://vube.com/vote/Siren+Gene/0nmsMY5vEq?n=2&t=s',
  73. 'md5': '0584fc13b50f887127d9d1007589d27f',
  74. 'info_dict': {
  75. 'id': '0nmsMY5vEq',
  76. 'ext': 'mp4',
  77. 'title': 'Frozen - Let It Go Cover by Siren Gene',
  78. 'description': 'My rendition of "Let It Go" originally sung by Idina Menzel.',
  79. 'thumbnail': 're:^http://frame\.thestaticvube\.com/snap/[0-9x]+/10283ab622a-86c9-4681-51f2-30d1f65774af\.jpg$',
  80. 'uploader': 'Siren',
  81. 'timestamp': 1395448018,
  82. 'upload_date': '20140322',
  83. 'duration': 221.788,
  84. 'like_count': int,
  85. 'dislike_count': int,
  86. 'comment_count': int,
  87. 'categories': ['let it go', 'cover', 'idina menzel', 'frozen', 'singing', 'disney', 'siren gene'],
  88. },
  89. 'skip': 'Removed due to DMCA',
  90. }
  91. ]
  92. def _real_extract(self, url):
  93. mobj = re.match(self._VALID_URL, url)
  94. video_id = mobj.group('id')
  95. video = self._download_json(
  96. 'http://vube.com/t-api/v1/video/%s' % video_id, video_id, 'Downloading video JSON')
  97. public_id = video['public_id']
  98. formats = []
  99. for media in video['media'].get('video', []) + video['media'].get('audio', []):
  100. if media['transcoding_status'] != 'processed':
  101. continue
  102. fmt = {
  103. 'url': 'http://video.thestaticvube.com/video/%s/%s.mp4' % (media['media_resolution_id'], public_id),
  104. 'abr': int(media['audio_bitrate']),
  105. 'format_id': compat_str(media['media_resolution_id']),
  106. }
  107. vbr = int(media['video_bitrate'])
  108. if vbr:
  109. fmt.update({
  110. 'vbr': vbr,
  111. 'height': int(media['height']),
  112. })
  113. formats.append(fmt)
  114. self._sort_formats(formats)
  115. if not formats and video.get('vst') == 'dmca':
  116. raise ExtractorError(
  117. 'This video has been removed in response to a complaint received under the US Digital Millennium Copyright Act.',
  118. expected=True)
  119. title = video['title']
  120. description = video.get('description')
  121. thumbnail = self._proto_relative_url(video.get('thumbnail_src'), scheme='http:')
  122. uploader = video.get('user_alias') or video.get('channel')
  123. timestamp = int_or_none(video.get('upload_time'))
  124. duration = video['duration']
  125. view_count = video.get('raw_view_count')
  126. like_count = video.get('total_likes')
  127. dislike_count = video.get('total_hates')
  128. comments = video.get('comments')
  129. comment_count = None
  130. if comments is None:
  131. comment_data = self._download_json(
  132. 'http://vube.com/api/video/%s/comment' % video_id,
  133. video_id, 'Downloading video comment JSON', fatal=False)
  134. if comment_data is not None:
  135. comment_count = int_or_none(comment_data.get('total'))
  136. else:
  137. comment_count = len(comments)
  138. categories = [tag['text'] for tag in video['tags']]
  139. return {
  140. 'id': video_id,
  141. 'formats': formats,
  142. 'title': title,
  143. 'description': description,
  144. 'thumbnail': thumbnail,
  145. 'uploader': uploader,
  146. 'timestamp': timestamp,
  147. 'duration': duration,
  148. 'view_count': view_count,
  149. 'like_count': like_count,
  150. 'dislike_count': dislike_count,
  151. 'comment_count': comment_count,
  152. 'categories': categories,
  153. }