]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/liveleak.py
Fix --list-formats description (Closes #2142)
[youtube-dl] / youtube_dl / extractor / liveleak.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import (
5     ExtractorError,
6 )
7
8
9 class LiveLeakIE(InfoExtractor):
10
11     _VALID_URL = r'^(?:http://)?(?:\w+\.)?liveleak\.com/view\?(?:.*?)i=(?P<video_id>[\w_]+)(?:.*)'
12     IE_NAME = u'liveleak'
13     _TEST = {
14         u'url': u'http://www.liveleak.com/view?i=757_1364311680',
15         u'file': u'757_1364311680.mp4',
16         u'md5': u'0813c2430bea7a46bf13acf3406992f4',
17         u'info_dict': {
18             u"description": u"extremely bad day for this guy..!", 
19             u"uploader": u"ljfriel2", 
20             u"title": u"Most unlucky car accident"
21         }
22     }
23
24     def _real_extract(self, url):
25         mobj = re.match(self._VALID_URL, url)
26         if mobj is None:
27             raise ExtractorError(u'Invalid URL: %s' % url)
28
29         video_id = mobj.group('video_id')
30
31         webpage = self._download_webpage(url, video_id)
32
33         video_url = self._search_regex(r'file: "(.*?)",',
34             webpage, u'video URL')
35
36         video_title = self._og_search_title(webpage).replace('LiveLeak.com -', '').strip()
37
38         video_description = self._og_search_description(webpage)
39
40         video_uploader = self._html_search_regex(r'By:.*?(\w+)</a>',
41             webpage, u'uploader', fatal=False)
42
43         info = {
44             'id':  video_id,
45             'url': video_url,
46             'ext': 'mp4',
47             'title': video_title,
48             'description': video_description,
49             'uploader': video_uploader
50         }
51
52         return [info]