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

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. ExtractorError,
  6. )
  7. class LiveLeakIE(InfoExtractor):
  8. _VALID_URL = r'^(?:http://)?(?:\w+\.)?liveleak\.com/view\?(?:.*?)i=(?P<video_id>[\w_]+)(?:.*)'
  9. _TEST = {
  10. 'url': 'http://www.liveleak.com/view?i=757_1364311680',
  11. 'file': '757_1364311680.mp4',
  12. 'md5': '0813c2430bea7a46bf13acf3406992f4',
  13. 'info_dict': {
  14. 'description': 'extremely bad day for this guy..!',
  15. 'uploader': 'ljfriel2',
  16. 'title': 'Most unlucky car accident'
  17. }
  18. }
  19. def _real_extract(self, url):
  20. mobj = re.match(self._VALID_URL, url)
  21. video_id = mobj.group('video_id')
  22. webpage = self._download_webpage(url, video_id)
  23. video_url = self._search_regex(
  24. r'file: "(.*?)",', webpage, 'video URL')
  25. video_title = self._og_search_title(webpage).replace('LiveLeak.com -', '').strip()
  26. video_description = self._og_search_description(webpage)
  27. video_uploader = self._html_search_regex(
  28. r'By:.*?(\w+)</a>', webpage, 'uploader', fatal=False)
  29. return {
  30. 'id': video_id,
  31. 'url': video_url,
  32. 'ext': 'mp4',
  33. 'title': video_title,
  34. 'description': video_description,
  35. 'uploader': video_uploader
  36. }