]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/streamcloud.py
[nfl] Fix test case - download, but don't check md5
[yt-dlp.git] / youtube_dl / extractor / streamcloud.py
CommitLineData
02e4ebbb 1# coding: utf-8
71aa656d
S
2from __future__ import unicode_literals
3
02e4ebbb
PH
4import re
5import time
6
7from .common import InfoExtractor
8from ..utils import (
9 compat_urllib_parse,
10 compat_urllib_request,
11)
12
13
14class StreamcloudIE(InfoExtractor):
71aa656d 15 IE_NAME = 'streamcloud.eu'
02e4ebbb
PH
16 _VALID_URL = r'https?://streamcloud\.eu/(?P<id>[a-zA-Z0-9_-]+)/(?P<fname>[^#?]*)\.html'
17
18 _TEST = {
71aa656d
S
19 'url': 'http://streamcloud.eu/skp9j99s4bpz/youtube-dl_test_video_____________-BaW_jenozKc.mp4.html',
20 'md5': '6bea4c7fa5daaacc2a946b7146286686',
21 'info_dict': {
22 'id': 'skp9j99s4bpz',
23 'ext': 'mp4',
24 'title': 'youtube-dl test video \'/\\ ä ↭',
02e4ebbb 25 },
71aa656d 26 'skip': 'Only available from the EU'
02e4ebbb
PH
27 }
28
29 def _real_extract(self, url):
30 mobj = re.match(self._VALID_URL, url)
31 video_id = mobj.group('id')
32
33 orig_webpage = self._download_webpage(url, video_id)
34
35 fields = re.findall(r'''(?x)<input\s+
36 type="(?:hidden|submit)"\s+
37 name="([^"]+)"\s+
38 (?:id="[^"]+"\s+)?
39 value="([^"]*)"
40 ''', orig_webpage)
41 post = compat_urllib_parse.urlencode(fields)
42
43 self.to_screen('%s: Waiting for timeout' % video_id)
44 time.sleep(12)
45 headers = {
46 b'Content-Type': b'application/x-www-form-urlencoded',
47 }
48 req = compat_urllib_request.Request(url, post, headers)
49
50 webpage = self._download_webpage(
71aa656d 51 req, video_id, note='Downloading video page ...')
02e4ebbb 52 title = self._html_search_regex(
71aa656d 53 r'<h1[^>]*>([^<]+)<', webpage, 'title')
02e4ebbb 54 video_url = self._search_regex(
71aa656d 55 r'file:\s*"([^"]+)"', webpage, 'video URL')
02e4ebbb 56 thumbnail = self._search_regex(
71aa656d 57 r'image:\s*"([^"]+)"', webpage, 'thumbnail URL', fatal=False)
02e4ebbb
PH
58
59 return {
60 'id': video_id,
61 'title': title,
62 'url': video_url,
02e4ebbb
PH
63 'thumbnail': thumbnail,
64 }