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