]>
Commit | Line | Data |
---|---|---|
537ba6f3 | 1 | # -*- coding: utf-8 -*- |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import re | |
1cc79574 | 5 | |
537ba6f3 | 6 | from .common import InfoExtractor |
1cc79574 | 7 | from ..compat import ( |
537ba6f3 | 8 | compat_urllib_parse, |
9 | compat_urllib_request, | |
10 | ) | |
11 | ||
12 | ||
13 | class VodlockerIE(InfoExtractor): | |
8904e979 | 14 | _VALID_URL = r'https?://(?:www\.)?vodlocker\.com/(?P<id>[0-9a-zA-Z]+)(?:\..*?)?' |
537ba6f3 | 15 | |
16 | _TESTS = [{ | |
17 | 'url': 'http://vodlocker.com/e8wvyzz4sl42', | |
18 | 'md5': 'ce0c2d18fa0735f1bd91b69b0e54aacf', | |
19 | 'info_dict': { | |
20 | 'id': 'e8wvyzz4sl42', | |
21 | 'ext': 'mp4', | |
22 | 'title': 'Germany vs Brazil', | |
23 | 'thumbnail': 're:http://.*\.jpg', | |
24 | }, | |
25 | }] | |
26 | ||
27 | def _real_extract(self, url): | |
1cc79574 | 28 | video_id = self._match_id(url) |
537ba6f3 | 29 | webpage = self._download_webpage(url, video_id) |
30 | ||
31 | fields = dict(re.findall(r'''(?x)<input\s+ | |
32 | type="hidden"\s+ | |
33 | name="([^"]+)"\s+ | |
34 | (?:id="[^"]+"\s+)? | |
35 | value="([^"]*)" | |
36 | ''', webpage)) | |
37 | ||
38 | if fields['op'] == 'download1': | |
4094b6e3 | 39 | self._sleep(3, video_id) # they do detect when requests happen too fast! |
537ba6f3 | 40 | post = compat_urllib_parse.urlencode(fields) |
41 | req = compat_urllib_request.Request(url, post) | |
42 | req.add_header('Content-type', 'application/x-www-form-urlencoded') | |
4094b6e3 PH |
43 | webpage = self._download_webpage( |
44 | req, video_id, 'Downloading video page') | |
537ba6f3 | 45 | |
4094b6e3 | 46 | title = self._search_regex( |
b7b04c92 | 47 | r'id="file_title".*?>\s*(.*?)\s*<(?:br|span)', webpage, 'title') |
4094b6e3 PH |
48 | thumbnail = self._search_regex( |
49 | r'image:\s*"(http[^\"]+)",', webpage, 'thumbnail') | |
50 | url = self._search_regex( | |
51 | r'file:\s*"(http[^\"]+)",', webpage, 'file url') | |
537ba6f3 | 52 | |
53 | formats = [{ | |
54 | 'format_id': 'sd', | |
55 | 'url': url, | |
537ba6f3 | 56 | }] |
57 | ||
58 | return { | |
59 | 'id': video_id, | |
60 | 'title': title, | |
61 | 'thumbnail': thumbnail, | |
62 | 'formats': formats, | |
63 | } |