]>
Commit | Line | Data |
---|---|---|
02e4ebbb | 1 | import re |
02e4ebbb PH |
2 | |
3 | from .common import InfoExtractor | |
6e6bc8da | 4 | from ..utils import ( |
84dcd1c4 | 5 | ExtractorError, |
6e6bc8da S |
6 | urlencode_postdata, |
7 | ) | |
02e4ebbb PH |
8 | |
9 | ||
10 | class StreamcloudIE(InfoExtractor): | |
71aa656d | 11 | IE_NAME = 'streamcloud.eu' |
3c6af203 | 12 | _VALID_URL = r'https?://streamcloud\.eu/(?P<id>[a-zA-Z0-9_-]+)(?:/(?P<fname>[^#?]*)\.html)?' |
02e4ebbb | 13 | |
84dcd1c4 | 14 | _TESTS = [{ |
7a5c1cfe | 15 | 'url': 'http://streamcloud.eu/skp9j99s4bpz/youtube-dl_test_video_____________-BaW_jenozKc.mp4.html', |
71aa656d S |
16 | 'md5': '6bea4c7fa5daaacc2a946b7146286686', |
17 | 'info_dict': { | |
18 | 'id': 'skp9j99s4bpz', | |
19 | 'ext': 'mp4', | |
7a5c1cfe | 20 | 'title': 'youtube-dl test video \'/\\ ä ↭', |
02e4ebbb | 21 | }, |
71aa656d | 22 | 'skip': 'Only available from the EU' |
84dcd1c4 S |
23 | }, { |
24 | 'url': 'http://streamcloud.eu/ua8cmfh1nbe6/NSHIP-148--KUC-NG--H264-.mp4.html', | |
25 | 'only_matching': True, | |
26 | }] | |
02e4ebbb PH |
27 | |
28 | def _real_extract(self, url): | |
3c6af203 NJ |
29 | video_id = self._match_id(url) |
30 | url = 'http://streamcloud.eu/%s' % video_id | |
02e4ebbb PH |
31 | |
32 | orig_webpage = self._download_webpage(url, video_id) | |
33 | ||
84dcd1c4 S |
34 | if '>File Not Found<' in orig_webpage: |
35 | raise ExtractorError( | |
36 | 'Video %s does not exist' % video_id, expected=True) | |
37 | ||
02e4ebbb PH |
38 | fields = re.findall(r'''(?x)<input\s+ |
39 | type="(?:hidden|submit)"\s+ | |
40 | name="([^"]+)"\s+ | |
41 | (?:id="[^"]+"\s+)? | |
42 | value="([^"]*)" | |
43 | ''', orig_webpage) | |
02e4ebbb | 44 | |
186d185b | 45 | self._sleep(6, video_id) |
02e4ebbb PH |
46 | |
47 | webpage = self._download_webpage( | |
feef925f S |
48 | url, video_id, data=urlencode_postdata(fields), headers={ |
49 | b'Content-Type': b'application/x-www-form-urlencoded', | |
50 | }) | |
51 | ||
52 | try: | |
53 | title = self._html_search_regex( | |
54 | r'<h1[^>]*>([^<]+)<', webpage, 'title') | |
55 | video_url = self._search_regex( | |
56 | r'file:\s*"([^"]+)"', webpage, 'video URL') | |
57 | except ExtractorError: | |
58 | message = self._html_search_regex( | |
59 | r'(?s)<div[^>]+class=(["\']).*?msgboxinfo.*?\1[^>]*>(?P<message>.+?)</div>', | |
60 | webpage, 'message', default=None, group='message') | |
61 | if message: | |
62 | raise ExtractorError('%s said: %s' % (self.IE_NAME, message), expected=True) | |
63 | raise | |
02e4ebbb | 64 | thumbnail = self._search_regex( |
71aa656d | 65 | r'image:\s*"([^"]+)"', webpage, 'thumbnail URL', fatal=False) |
02e4ebbb PH |
66 | |
67 | return { | |
68 | 'id': video_id, | |
69 | 'title': title, | |
70 | 'url': video_url, | |
02e4ebbb | 71 | 'thumbnail': thumbnail, |
b5dec62c S |
72 | 'http_headers': { |
73 | 'Referer': url, | |
74 | }, | |
02e4ebbb | 75 | } |