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.

56 lines
1.9 KiB

  1. import re
  2. import json
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. compat_urlparse,
  6. get_element_by_id,
  7. clean_html,
  8. )
  9. class VeeHDIE(InfoExtractor):
  10. _VALID_URL = r'https?://veehd\.com/video/(?P<id>\d+)'
  11. _TEST = {
  12. u'url': u'http://veehd.com/video/4686958',
  13. u'file': u'4686958.mp4',
  14. u'info_dict': {
  15. u'title': u'Time Lapse View from Space ( ISS)',
  16. u'uploader_id': u'spotted',
  17. u'description': u'md5:f0094c4cf3a72e22bc4e4239ef767ad7',
  18. },
  19. }
  20. def _real_extract(self, url):
  21. mobj = re.match(self._VALID_URL, url)
  22. video_id = mobj.group('id')
  23. webpage = self._download_webpage(url, video_id)
  24. player_path = self._search_regex(r'\$\("#playeriframe"\).attr\({src : "(.+?)"',
  25. webpage, u'player path')
  26. player_url = compat_urlparse.urljoin(url, player_path)
  27. player_page = self._download_webpage(player_url, video_id,
  28. u'Downloading player page')
  29. config_json = self._search_regex(r'value=\'config=({.+?})\'',
  30. player_page, u'config json')
  31. config = json.loads(config_json)
  32. video_url = compat_urlparse.unquote(config['clip']['url'])
  33. title = clean_html(get_element_by_id('videoName', webpage).rpartition('|')[0])
  34. uploader_id = self._html_search_regex(r'<a href="/profile/\d+">(.+?)</a>',
  35. webpage, u'uploader')
  36. thumbnail = self._search_regex(r'<img id="veehdpreview" src="(.+?)"',
  37. webpage, u'thumbnail')
  38. description = self._html_search_regex(r'<td class="infodropdown".*?<div>(.*?)<ul',
  39. webpage, u'description', flags=re.DOTALL)
  40. return {
  41. '_type': 'video',
  42. 'id': video_id,
  43. 'title': title,
  44. 'url': video_url,
  45. 'ext': 'mp4',
  46. 'uploader_id': uploader_id,
  47. 'thumbnail': thumbnail,
  48. 'description': description,
  49. }