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