2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..utils import encode_dict
14 class VidtoIE(InfoExtractor):
17 _VALID_URL = r'https?://(?:www\.)?vidto\.me/(?P<id>[0-9a-zA-Z]+)\.html'
20 'url': 'http://vidto.me/ku5glz52nqe1.html',
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
31 page = self._download_webpage(
32 'http://%s/%s.html' % (self._HOST, video_id), video_id, 'Downloading video page')
33 hash_regex = r'<input type="hidden" name="hash" value="(.*)">'
34 hash_value = self._search_regex(hash_regex, page, 'hash', fatal=True)
35 title_regex = r'<input type="hidden" name="fname" value="(.*)">'
36 title = self._search_regex(title_regex, page, 'title', fatal=False)
37 id_regex = r'<input type="hidden" name="id" value="(.*)">'
38 id_value = self._search_regex(id_regex, page, 'id', fatal=True)
39 cookies = self._get_cookies('http://%s/%s.html' % (self._HOST, video_id))
43 'imhuman': 'Proceed to video',
50 post_data = compat_urllib_parse.urlencode(encode_dict(form_str)).encode('ascii')
51 req = compat_urllib_request.Request(url, post_data)
52 req.add_header('Content-type', 'application/x-www-form-urlencoded')
54 for key in cookies.keys():
55 cookie_string += "%s=%s;" % (key, cookies[key].value)
57 req.add_header('Cookie', '%s' % cookie_string)
59 self.to_screen("Waiting for countdown...")
61 post_result = self._download_webpage(
63 note='Proceed to video...', errnote='unable to proceed')
65 file_link_regex = r'file_link\s*=\s*\'(https?:\/\/[0-9a-zA-z.\/\-_]+)'
66 file_link = self._search_regex(file_link_regex, post_result, 'file_link')