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.

78 lines
2.8 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. import datetime
  4. from .common import InfoExtractor
  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})'
  9. _TEST = {
  10. 'url': 'http://vube.com/Chiara+Grispo+Video+Channel/YL2qNPkqon',
  11. 'file': 'YL2qNPkqon.mp4',
  12. 'md5': 'f81dcf6d0448e3291f54380181695821',
  13. 'info_dict': {
  14. 'title': 'Chiara Grispo - Price Tag by Jessie J',
  15. 'description': 'md5:8ea652a1f36818352428cb5134933313',
  16. 'thumbnail': 'http://frame.thestaticvube.com/snap/228x128/102e7e63057-5ebc-4f5c-4065-6ce4ebde131f.jpg',
  17. 'uploader': 'Chiara.Grispo',
  18. 'uploader_id': '1u3hX0znhP',
  19. 'upload_date': '20140103',
  20. 'duration': 170.56
  21. }
  22. }
  23. def _real_extract(self, url):
  24. mobj = re.match(self._VALID_URL, url)
  25. video_id = mobj.group('id')
  26. video = self._download_json('http://vube.com/api/v2/video/%s' % video_id,
  27. video_id, 'Downloading video JSON')
  28. public_id = video['public_id']
  29. formats = [{'url': 'http://video.thestaticvube.com/video/%s/%s.mp4' % (fmt['media_resolution_id'], public_id),
  30. 'height': int(fmt['height']),
  31. 'abr': int(fmt['audio_bitrate']),
  32. 'vbr': int(fmt['video_bitrate']),
  33. 'format_id': fmt['media_resolution_id']
  34. } for fmt in video['mtm'] if fmt['transcoding_status'] == 'processed']
  35. self._sort_formats(formats)
  36. title = video['title']
  37. description = video.get('description')
  38. thumbnail = video['thumbnail_src']
  39. if thumbnail.startswith('//'):
  40. thumbnail = 'http:' + thumbnail
  41. uploader = video['user_alias']
  42. uploader_id = video['user_url_id']
  43. upload_date = datetime.datetime.fromtimestamp(int(video['upload_time'])).strftime('%Y%m%d')
  44. duration = video['duration']
  45. view_count = video['raw_view_count']
  46. like_count = video['total_likes']
  47. dislike_count= video['total_hates']
  48. comment = self._download_json('http://vube.com/api/video/%s/comment' % video_id,
  49. video_id, 'Downloading video comment JSON')
  50. comment_count = comment['total']
  51. return {
  52. 'id': video_id,
  53. 'formats': formats,
  54. 'title': title,
  55. 'description': description,
  56. 'thumbnail': thumbnail,
  57. 'uploader': uploader,
  58. 'uploader_id': uploader_id,
  59. 'upload_date': upload_date,
  60. 'duration': duration,
  61. 'view_count': view_count,
  62. 'like_count': like_count,
  63. 'dislike_count': dislike_count,
  64. 'comment_count': comment_count,
  65. }