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.

47 lines
1.8 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. import json
  4. from .common import InfoExtractor
  5. class VeohIE(InfoExtractor):
  6. _VALID_URL = r'http://(?:www\.)?veoh\.com/(?:watch|iphone/#_Watch)/v(?P<id>\d*)'
  7. _TEST = {
  8. 'url': 'http://www.veoh.com/watch/v56314296nk7Zdmz3',
  9. 'file': '56314296.mp4',
  10. 'md5': '620e68e6a3cff80086df3348426c9ca3',
  11. 'info_dict': {
  12. 'title': 'Straight Backs Are Stronger',
  13. 'uploader': 'LUMOback',
  14. '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. ',
  15. }
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. video_id = mobj.group('id')
  20. webpage = self._download_webpage(url, video_id)
  21. m_youtube = re.search(r'http://www\.youtube\.com/v/(.*?)(\&|")', webpage)
  22. if m_youtube is not None:
  23. youtube_id = m_youtube.group(1)
  24. self.to_screen('%s: detected Youtube video.' % video_id)
  25. return self.url_result(youtube_id, 'Youtube')
  26. self.report_extraction(video_id)
  27. info = self._search_regex(r'videoDetailsJSON = \'({.*?})\';', webpage, 'info')
  28. info = json.loads(info)
  29. video_url = info.get('fullPreviewHashHighPath') or info.get('fullPreviewHashLowPath')
  30. return {
  31. 'id': info['videoId'],
  32. 'title': info['title'],
  33. 'url': video_url,
  34. 'uploader': info['username'],
  35. 'thumbnail': info.get('highResImage') or info.get('medResImage'),
  36. 'description': info['description'],
  37. 'view_count': info['views'],
  38. }