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.

103 lines
3.9 KiB

11 years ago
11 years ago
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. int_or_none,
  5. parse_duration,
  6. qualities,
  7. )
  8. class VeohIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?veoh\.com/(?:watch|embed|iphone/#_Watch)/(?P<id>(?:v|e|yapi-)[\da-zA-Z]+)'
  10. _TESTS = [{
  11. 'url': 'http://www.veoh.com/watch/v56314296nk7Zdmz3',
  12. 'md5': '9e7ecc0fd8bbee7a69fe38953aeebd30',
  13. 'info_dict': {
  14. 'id': 'v56314296nk7Zdmz3',
  15. 'ext': 'mp4',
  16. 'title': 'Straight Backs Are Stronger',
  17. 'uploader': 'LUMOback',
  18. 'description': 'At LUMOback, we believe straight backs are stronger. The LUMOback Posture & Movement Sensor: It gently vibrates when you slouch, inspiring improved posture and mobility. Use the app to track your data and improve your posture over time. ',
  19. },
  20. }, {
  21. 'url': 'http://www.veoh.com/embed/v56314296nk7Zdmz3',
  22. 'only_matching': True,
  23. }, {
  24. 'url': 'http://www.veoh.com/watch/v27701988pbTc4wzN?h1=Chile+workers+cover+up+to+avoid+skin+damage',
  25. 'md5': '4a6ff84b87d536a6a71e6aa6c0ad07fa',
  26. 'info_dict': {
  27. 'id': '27701988',
  28. 'ext': 'mp4',
  29. 'title': 'Chile workers cover up to avoid skin damage',
  30. 'description': 'md5:2bd151625a60a32822873efc246ba20d',
  31. 'uploader': 'afp-news',
  32. 'duration': 123,
  33. },
  34. 'skip': 'This video has been deleted.',
  35. }, {
  36. 'url': 'http://www.veoh.com/watch/v69525809F6Nc4frX',
  37. 'md5': '4fde7b9e33577bab2f2f8f260e30e979',
  38. 'note': 'Embedded ooyala video',
  39. 'info_dict': {
  40. 'id': '69525809',
  41. 'ext': 'mp4',
  42. 'title': 'Doctors Alter Plan For Preteen\'s Weight Loss Surgery',
  43. 'description': 'md5:f5a11c51f8fb51d2315bca0937526891',
  44. 'uploader': 'newsy-videos',
  45. },
  46. 'skip': 'This video has been deleted.',
  47. }, {
  48. 'url': 'http://www.veoh.com/watch/e152215AJxZktGS',
  49. 'only_matching': True,
  50. }]
  51. def _extract_video(self, source):
  52. return {
  53. 'id': source.get('videoId'),
  54. 'title': source.get('title'),
  55. 'description': source.get('description'),
  56. 'thumbnail': source.get('highResImage') or source.get('medResImage'),
  57. 'uploader': source.get('username'),
  58. 'duration': int_or_none(source.get('length')),
  59. 'view_count': int_or_none(source.get('views')),
  60. 'age_limit': 18 if source.get('isMature') == 'true' or source.get('isSexy') == 'true' else 0,
  61. 'formats': self._extract_formats(source),
  62. }
  63. def _real_extract(self, url):
  64. video_id = self._match_id(url)
  65. video = self._download_json(
  66. 'https://www.veoh.com/watch/getVideo/' + video_id,
  67. video_id)['video']
  68. title = video['title']
  69. thumbnail_url = None
  70. q = qualities(['HQ', 'Regular'])
  71. formats = []
  72. for f_id, f_url in video.get('src', {}).items():
  73. if not f_url:
  74. continue
  75. if f_id == 'poster':
  76. thumbnail_url = f_url
  77. else:
  78. formats.append({
  79. 'format_id': f_id,
  80. 'quality': q(f_id),
  81. 'url': f_url,
  82. })
  83. self._sort_formats(formats)
  84. return {
  85. 'id': video_id,
  86. 'title': title,
  87. 'description': video.get('description'),
  88. 'thumbnail': thumbnail_url,
  89. 'uploader': video.get('author', {}).get('nickname'),
  90. 'duration': int_or_none(video.get('lengthBySec')) or parse_duration(video.get('length')),
  91. 'view_count': int_or_none(video.get('views')),
  92. 'formats': formats,
  93. 'average_rating': int_or_none(video.get('rating')),
  94. 'comment_count': int_or_none(video.get('numOfComments')),
  95. }