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.

65 lines
2.2 KiB

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