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.

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