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.

52 lines
1.5 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. _TEST = {
  10. u'url': u'http://www.liveleak.com/view?i=757_1364311680',
  11. u'file': u'757_1364311680.mp4',
  12. u'md5': u'0813c2430bea7a46bf13acf3406992f4',
  13. u'info_dict': {
  14. u"description": u"extremely bad day for this guy..!",
  15. u"uploader": u"ljfriel2",
  16. u"title": u"Most unlucky car accident"
  17. }
  18. }
  19. def _real_extract(self, url):
  20. mobj = re.match(self._VALID_URL, url)
  21. if mobj is None:
  22. raise ExtractorError(u'Invalid URL: %s' % url)
  23. video_id = mobj.group('video_id')
  24. webpage = self._download_webpage(url, video_id)
  25. video_url = self._search_regex(r'file: "(.*?)",',
  26. webpage, u'video URL')
  27. video_title = self._og_search_title(webpage).replace('LiveLeak.com -', '').strip()
  28. video_description = self._og_search_description(webpage)
  29. video_uploader = self._html_search_regex(r'By:.*?(\w+)</a>',
  30. webpage, u'uploader', fatal=False)
  31. info = {
  32. 'id': video_id,
  33. 'url': video_url,
  34. 'ext': 'mp4',
  35. 'title': video_title,
  36. 'description': video_description,
  37. 'uploader': video_uploader
  38. }
  39. return [info]