]>
Commit | Line | Data |
---|---|---|
537ba6f3 | 1 | from .common import InfoExtractor |
af284305 S |
2 | from ..utils import ( |
3 | ExtractorError, | |
fbd90643 | 4 | NO_DEFAULT, |
af284305 | 5 | sanitized_Request, |
6e6bc8da | 6 | urlencode_postdata, |
af284305 | 7 | ) |
537ba6f3 | 8 | |
9 | ||
10 | class VodlockerIE(InfoExtractor): | |
fbd90643 | 11 | _VALID_URL = r'https?://(?:www\.)?vodlocker\.(?:com|city)/(?:embed-)?(?P<id>[0-9a-zA-Z]+)(?:\..*?)?' |
537ba6f3 | 12 | |
13 | _TESTS = [{ | |
14 | 'url': 'http://vodlocker.com/e8wvyzz4sl42', | |
15 | 'md5': 'ce0c2d18fa0735f1bd91b69b0e54aacf', | |
16 | 'info_dict': { | |
17 | 'id': 'e8wvyzz4sl42', | |
18 | 'ext': 'mp4', | |
19 | 'title': 'Germany vs Brazil', | |
ec85ded8 | 20 | 'thumbnail': r're:http://.*\.jpg', |
537ba6f3 | 21 | }, |
22 | }] | |
23 | ||
24 | def _real_extract(self, url): | |
1cc79574 | 25 | video_id = self._match_id(url) |
537ba6f3 | 26 | webpage = self._download_webpage(url, video_id) |
27 | ||
af284305 S |
28 | if any(p in webpage for p in ( |
29 | '>THIS FILE WAS DELETED<', | |
30 | '>File Not Found<', | |
32f2627a S |
31 | 'The file you were looking for could not be found, sorry for any inconvenience.<', |
32 | '>The file was removed')): | |
af284305 S |
33 | raise ExtractorError('Video %s does not exist' % video_id, expected=True) |
34 | ||
f8da79f8 | 35 | fields = self._hidden_inputs(webpage) |
537ba6f3 | 36 | |
37 | if fields['op'] == 'download1': | |
4094b6e3 | 38 | self._sleep(3, video_id) # they do detect when requests happen too fast! |
6e6bc8da | 39 | post = urlencode_postdata(fields) |
5c2266df | 40 | req = sanitized_Request(url, post) |
537ba6f3 | 41 | req.add_header('Content-type', 'application/x-www-form-urlencoded') |
4094b6e3 PH |
42 | webpage = self._download_webpage( |
43 | req, video_id, 'Downloading video page') | |
537ba6f3 | 44 | |
fbd90643 S |
45 | def extract_file_url(html, default=NO_DEFAULT): |
46 | return self._search_regex( | |
47 | r'file:\s*"(http[^\"]+)",', html, 'file url', default=default) | |
48 | ||
49 | video_url = extract_file_url(webpage, default=None) | |
50 | ||
51 | if not video_url: | |
52 | embed_url = self._search_regex( | |
53 | r'<iframe[^>]+src=(["\'])(?P<url>(?:https?://)?vodlocker\.(?:com|city)/embed-.+?)\1', | |
54 | webpage, 'embed url', group='url') | |
55 | embed_webpage = self._download_webpage( | |
56 | embed_url, video_id, 'Downloading embed webpage') | |
57 | video_url = extract_file_url(embed_webpage) | |
58 | thumbnail_webpage = embed_webpage | |
59 | else: | |
60 | thumbnail_webpage = webpage | |
61 | ||
4094b6e3 | 62 | title = self._search_regex( |
b7b04c92 | 63 | r'id="file_title".*?>\s*(.*?)\s*<(?:br|span)', webpage, 'title') |
4094b6e3 | 64 | thumbnail = self._search_regex( |
fbd90643 | 65 | r'image:\s*"(http[^\"]+)",', thumbnail_webpage, 'thumbnail', fatal=False) |
537ba6f3 | 66 | |
67 | formats = [{ | |
68 | 'format_id': 'sd', | |
fbd90643 | 69 | 'url': video_url, |
537ba6f3 | 70 | }] |
71 | ||
72 | return { | |
73 | 'id': video_id, | |
74 | 'title': title, | |
75 | 'thumbnail': thumbnail, | |
76 | 'formats': formats, | |
77 | } |