2 from __future__ import unicode_literals
6 from .common import InfoExtractor
12 from ..compat import (
16 compat_urllib_parse_unquote,
17 compat_urllib_parse_unquote_plus,
18 compat_urllib_parse_urlparse,
19 compat_urllib_request,
25 class VidtoIE(InfoExtractor):
28 _VALID_URL = r'https?://(?:www\.)?vidto\.me/(?P<id>[0-9a-zA-Z]+)\.html'
31 'url': 'http://vidto.me/ku5glz52nqe1.html',
39 def _real_extract(self, url):
40 mobj = re.match(self._VALID_URL, url)
41 video_id = mobj.group('id')
43 page = self._download_webpage(
44 'http://%s/%s.html' % (self._HOST, video_id), video_id, 'Downloading video page')
45 hash_regex = r'<input type="hidden" name="hash" value="(.*)">'
46 hash_value = self._search_regex(hash_regex, page, 'hash', fatal=True)
47 title_regex = r'<input type="hidden" name="fname" value="(.*)">'
48 title = self._search_regex(title_regex, page, 'title', fatal=False)
49 id_regex = r'<input type="hidden" name="id" value="(.*)">'
50 id_value = self._search_regex(id_regex, page, 'id', fatal=True)
51 cookies = self._get_cookies('http://%s/%s.html' % (self._HOST, video_id))
56 'imhuman': 'Proceed to video',
63 post_data = compat_urllib_parse.urlencode(encode_dict(form_str)).encode('ascii')
64 req = compat_urllib_request.Request(url, post_data)
65 req.add_header('Content-type', 'application/x-www-form-urlencoded')
66 for key, morsel in cookies.iteritems():
67 req.add_header('Cookie', '%s=%s' % (morsel.key, morsel.value))
69 print("Waiting for countdown...")
71 post_result = self._download_webpage(
73 note='Proceed to video...', errnote='unable to proceed', fatal=True)
75 file_link_regex = r'file_link ?= ?\'(https?:\/\/[0-9a-zA-z.\/\-_]+)'
76 file_link = self._search_regex(file_link_regex, post_result, 'file_link', fatal=True)