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.

102 lines
3.7 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import int_or_none
  5. class VubeIE(InfoExtractor):
  6. IE_NAME = 'vube'
  7. IE_DESC = 'Vube.com'
  8. _VALID_URL = r'http://vube\.com/(?:[^/]+/)+(?P<id>[\da-zA-Z]{10})\b'
  9. _TESTS = [
  10. {
  11. 'url': 'http://vube.com/Chiara+Grispo+Video+Channel/YL2qNPkqon',
  12. 'md5': 'db7aba89d4603dadd627e9d1973946fe',
  13. 'info_dict': {
  14. 'id': 'YL2qNPkqon',
  15. 'ext': 'mp4',
  16. 'title': 'Chiara Grispo - Price Tag by Jessie J',
  17. 'description': 'md5:8ea652a1f36818352428cb5134933313',
  18. 'thumbnail': 'http://frame.thestaticvube.com/snap/228x128/102e7e63057-5ebc-4f5c-4065-6ce4ebde131f.jpg',
  19. 'uploader': 'Chiara.Grispo',
  20. 'uploader_id': '1u3hX0znhP',
  21. 'timestamp': 1388743358,
  22. 'upload_date': '20140103',
  23. 'duration': 170.56
  24. }
  25. },
  26. {
  27. 'url': 'http://vube.com/SerainaMusic/my-7-year-old-sister-and-i-singing-alive-by-krewella/UeBhTudbfS?t=s&n=1',
  28. 'md5': '5d4a52492d76f72712117ce6b0d98d08',
  29. 'info_dict': {
  30. 'id': 'UeBhTudbfS',
  31. 'ext': 'mp4',
  32. 'title': 'My 7 year old Sister and I singing "Alive" by Krewella',
  33. 'description': 'md5:40bcacb97796339f1690642c21d56f4a',
  34. 'thumbnail': 'http://frame.thestaticvube.com/snap/228x128/102265d5a9f-0f17-4f6b-5753-adf08484ee1e.jpg',
  35. 'uploader': 'Seraina',
  36. 'uploader_id': 'XU9VE2BQ2q',
  37. 'timestamp': 1396492438,
  38. 'upload_date': '20140403',
  39. 'duration': 240.107
  40. }
  41. }
  42. ]
  43. def _real_extract(self, url):
  44. mobj = re.match(self._VALID_URL, url)
  45. video_id = mobj.group('id')
  46. video = self._download_json(
  47. 'http://vube.com/api/v2/video/%s' % video_id, video_id, 'Downloading video JSON')
  48. public_id = video['public_id']
  49. formats = [
  50. {
  51. 'url': 'http://video.thestaticvube.com/video/%s/%s.mp4' % (fmt['media_resolution_id'], public_id),
  52. 'height': int(fmt['height']),
  53. 'abr': int(fmt['audio_bitrate']),
  54. 'vbr': int(fmt['video_bitrate']),
  55. 'format_id': fmt['media_resolution_id']
  56. } for fmt in video['mtm'] if fmt['transcoding_status'] == 'processed'
  57. ]
  58. self._sort_formats(formats)
  59. title = video['title']
  60. description = video.get('description')
  61. thumbnail = video['thumbnail_src']
  62. if thumbnail.startswith('//'):
  63. thumbnail = 'http:' + thumbnail
  64. uploader = video['user_alias']
  65. uploader_id = video['user_url_id']
  66. timestamp = int(video['upload_time'])
  67. duration = video['duration']
  68. view_count = video.get('raw_view_count')
  69. like_count = video.get('total_likes')
  70. dislike_count= video.get('total_hates')
  71. comment = self._download_json(
  72. 'http://vube.com/api/video/%s/comment' % video_id, video_id, 'Downloading video comment JSON')
  73. comment_count = int_or_none(comment.get('total'))
  74. return {
  75. 'id': video_id,
  76. 'formats': formats,
  77. 'title': title,
  78. 'description': description,
  79. 'thumbnail': thumbnail,
  80. 'uploader': uploader,
  81. 'uploader_id': uploader_id,
  82. 'timestamp': timestamp,
  83. 'duration': duration,
  84. 'view_count': view_count,
  85. 'like_count': like_count,
  86. 'dislike_count': dislike_count,
  87. 'comment_count': comment_count,
  88. }