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.

171 lines
6.7 KiB

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