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.9 KiB

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