1 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..utils import int_or_none
10 class LiveLeakIE(InfoExtractor):
11 _VALID_URL = r'https?://(?:\w+\.)?liveleak\.com/view\?(?:.*?)i=(?P<id>[\w_]+)(?:.*)'
13 'url': 'http://www.liveleak.com/view?i=757_1364311680',
14 'md5': '50f79e05ba149149c1b4ea961223d5b3',
16 'id': '757_1364311680',
18 'description': 'extremely bad day for this guy..!',
19 'uploader': 'ljfriel2',
20 'title': 'Most unlucky car accident'
23 'url': 'http://www.liveleak.com/view?i=f93_1390833151',
24 'md5': 'b13a29626183c9d33944e6a04f41aafc',
26 'id': 'f93_1390833151',
28 'description': 'German Television Channel NDR does an exclusive interview with Edward Snowden.\r\nUploaded on LiveLeak cause German Television thinks the rest of the world isn\'t intereseted in Edward Snowden.',
29 'uploader': 'ARD_Stinkt',
30 'title': 'German Television does first Edward Snowden Interview (ENGLISH)',
33 'url': 'http://www.liveleak.com/view?i=4f7_1392687779',
34 'md5': '42c6d97d54f1db107958760788c5f48f',
36 'id': '4f7_1392687779',
38 'description': "The guy with the cigarette seems amazingly nonchalant about the whole thing... I really hope my friends' reactions would be a bit stronger.\r\n\r\nAction-go to 0:55.",
39 'uploader': 'CapObveus',
40 'title': 'Man is Fatally Struck by Reckless Car While Packing up a Moving Truck',
44 'url': 'http://www.liveleak.com/view?i=801_1409392012',
45 'md5': '0b3bec2d888c20728ca2ad3642f0ef15',
47 'id': '801_1409392012',
49 'description': "Happened on 27.7.2014. \r\nAt 0:53 you can see people still swimming at near beach.",
50 'uploader': 'bony333',
51 'title': 'Crazy Hungarian tourist films close call waterspout in Croatia'
55 def _real_extract(self, url):
56 video_id = self._match_id(url)
57 webpage = self._download_webpage(url, video_id)
59 video_title = self._og_search_title(webpage).replace('LiveLeak.com -', '').strip()
60 video_description = self._og_search_description(webpage)
61 video_uploader = self._html_search_regex(
62 r'By:.*?(\w+)</a>', webpage, 'uploader', fatal=False)
63 age_limit = int_or_none(self._search_regex(
64 r'you confirm that you are ([0-9]+) years and over.',
65 webpage, 'age limit', default=None))
67 sources_raw = self._search_regex(
68 r'(?s)sources:\s*(\[.*?\]),', webpage, 'video URLs', default=None)
69 if sources_raw is None:
70 alt_source = self._search_regex(
71 r'(file: ".*?"),', webpage, 'video URL', default=None)
73 sources_raw = '[{ %s}]' % alt_source
76 embed_url = self._search_regex(
77 r'<iframe[^>]+src="(http://www.prochan.com/embed\?[^"]+)"',
80 '_type': 'url_transparent',
84 'description': video_description,
85 'uploader': video_uploader,
86 'age_limit': age_limit,
89 sources_json = re.sub(r'\s([a-z]+):\s', r'"\1": ', sources_raw)
90 sources = json.loads(sources_json)
93 'format_id': '%s' % i,
94 'format_note': s.get('label'),
96 } for i, s in enumerate(sources)]
97 for i, s in enumerate(sources):
98 orig_url = re.sub(r'.h264_.+\.mp4', '', s['file'])
99 if s['file'] != orig_url:
101 'format_id': 'original-%s' % i,
102 'format_note': s.get('label'),
106 self._sort_formats(formats)
110 'title': video_title,
111 'description': video_description,
112 'uploader': video_uploader,
114 'age_limit': age_limit,