]>
Commit | Line | Data |
---|---|---|
02e4ebbb | 1 | # coding: utf-8 |
71aa656d S |
2 | from __future__ import unicode_literals |
3 | ||
02e4ebbb | 4 | import re |
02e4ebbb PH |
5 | |
6 | from .common import InfoExtractor | |
6e6bc8da S |
7 | from ..utils import ( |
8 | sanitized_Request, | |
9 | urlencode_postdata, | |
10 | ) | |
02e4ebbb PH |
11 | |
12 | ||
13 | class StreamcloudIE(InfoExtractor): | |
71aa656d | 14 | IE_NAME = 'streamcloud.eu' |
3c6af203 | 15 | _VALID_URL = r'https?://streamcloud\.eu/(?P<id>[a-zA-Z0-9_-]+)(?:/(?P<fname>[^#?]*)\.html)?' |
02e4ebbb PH |
16 | |
17 | _TEST = { | |
71aa656d S |
18 | 'url': 'http://streamcloud.eu/skp9j99s4bpz/youtube-dl_test_video_____________-BaW_jenozKc.mp4.html', |
19 | 'md5': '6bea4c7fa5daaacc2a946b7146286686', | |
20 | 'info_dict': { | |
21 | 'id': 'skp9j99s4bpz', | |
22 | 'ext': 'mp4', | |
23 | 'title': 'youtube-dl test video \'/\\ ä ↭', | |
02e4ebbb | 24 | }, |
71aa656d | 25 | 'skip': 'Only available from the EU' |
02e4ebbb PH |
26 | } |
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 | ||
34 | fields = re.findall(r'''(?x)<input\s+ | |
35 | type="(?:hidden|submit)"\s+ | |
36 | name="([^"]+)"\s+ | |
37 | (?:id="[^"]+"\s+)? | |
38 | value="([^"]*)" | |
39 | ''', orig_webpage) | |
6e6bc8da | 40 | post = urlencode_postdata(fields) |
02e4ebbb | 41 | |
6f9b5493 | 42 | self._sleep(12, video_id) |
02e4ebbb PH |
43 | headers = { |
44 | b'Content-Type': b'application/x-www-form-urlencoded', | |
45 | } | |
5c2266df | 46 | req = sanitized_Request(url, post, headers) |
02e4ebbb PH |
47 | |
48 | webpage = self._download_webpage( | |
71aa656d | 49 | req, video_id, note='Downloading video page ...') |
02e4ebbb | 50 | title = self._html_search_regex( |
71aa656d | 51 | r'<h1[^>]*>([^<]+)<', webpage, 'title') |
02e4ebbb | 52 | video_url = self._search_regex( |
71aa656d | 53 | r'file:\s*"([^"]+)"', webpage, 'video URL') |
02e4ebbb | 54 | thumbnail = self._search_regex( |
71aa656d | 55 | r'image:\s*"([^"]+)"', webpage, 'thumbnail URL', fatal=False) |
02e4ebbb PH |
56 | |
57 | return { | |
58 | 'id': video_id, | |
59 | 'title': title, | |
60 | 'url': video_url, | |
02e4ebbb PH |
61 | 'thumbnail': thumbnail, |
62 | } |