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.

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