]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/liveleak.py
Imported Upstream version 2013.07.02
[youtubedl] / 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._html_search_regex(r'<meta property="og:title" content="(?P<title>.*?)"',
37 webpage, u'title').replace('LiveLeak.com -', '').strip()
38
39 video_description = self._html_search_regex(r'<meta property="og:description" content="(?P<desc>.*?)"',
40 webpage, u'description', fatal=False)
41
42 video_uploader = self._html_search_regex(r'By:.*?(\w+)</a>',
43 webpage, u'uploader', fatal=False)
44
45 info = {
46 'id': video_id,
47 'url': video_url,
48 'ext': 'mp4',
49 'title': video_title,
50 'description': video_description,
51 'uploader': video_uploader
52 }
53
54 return [info]