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.

44 lines
1.3 KiB

  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. ExtractorError,
  5. )
  6. class LiveLeakIE(InfoExtractor):
  7. _VALID_URL = r'^(?:http?://)?(?:\w+\.)?liveleak\.com/view\?(?:.*?)i=(?P<video_id>[\w_]+)(?:.*)'
  8. IE_NAME = u'liveleak'
  9. def _real_extract(self, url):
  10. mobj = re.match(self._VALID_URL, url)
  11. if mobj is None:
  12. raise ExtractorError(u'Invalid URL: %s' % url)
  13. video_id = mobj.group('video_id')
  14. webpage = self._download_webpage(url, video_id)
  15. video_url = self._search_regex(r'file: "(.*?)",',
  16. webpage, u'video URL')
  17. video_title = self._html_search_regex(r'<meta property="og:title" content="(?P<title>.*?)"',
  18. webpage, u'title').replace('LiveLeak.com -', '').strip()
  19. video_description = self._html_search_regex(r'<meta property="og:description" content="(?P<desc>.*?)"',
  20. webpage, u'description', fatal=False)
  21. video_uploader = self._html_search_regex(r'By:.*?(\w+)</a>',
  22. webpage, u'uploader', fatal=False)
  23. info = {
  24. 'id': video_id,
  25. 'url': video_url,
  26. 'ext': 'mp4',
  27. 'title': video_title,
  28. 'description': video_description,
  29. 'uploader': video_uploader
  30. }
  31. return [info]