2015-10-14 05:11:52 -04:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
2015-11-11 07:13:03 -05:00
|
|
|
from .common import InfoExtractor
|
2015-11-11 10:17:59 -05:00
|
|
|
from ..utils import (
|
|
|
|
encode_dict,
|
|
|
|
remove_end,
|
|
|
|
urlencode_postdata,
|
2015-10-14 05:11:52 -04:00
|
|
|
)
|
2015-11-11 10:17:59 -05:00
|
|
|
from ..compat import compat_urllib_request
|
2015-10-14 05:11:52 -04:00
|
|
|
|
|
|
|
|
|
|
|
class VidtoIE(InfoExtractor):
|
|
|
|
IE_NAME = 'vidto'
|
|
|
|
IE_DESC = 'VidTo.me'
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?vidto\.me/(?P<id>[0-9a-zA-Z]+)\.html'
|
|
|
|
_TEST = {
|
|
|
|
'url': 'http://vidto.me/ku5glz52nqe1.html',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'ku5glz52nqe1',
|
|
|
|
'ext': 'mp4',
|
2015-11-11 10:17:59 -05:00
|
|
|
'title': 'test'
|
2015-10-14 05:11:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2015-10-17 13:35:41 -04:00
|
|
|
video_id = self._match_id(url)
|
2015-10-14 05:11:52 -04:00
|
|
|
|
|
|
|
page = self._download_webpage(
|
2015-11-11 10:17:59 -05:00
|
|
|
'http://vidto.me/%s.html' % video_id, video_id, 'Downloading video page')
|
2015-10-14 05:11:52 -04:00
|
|
|
|
2015-11-11 10:17:59 -05:00
|
|
|
title = remove_end(self._html_search_regex(
|
|
|
|
r'<Title>\s*([^<]+)\s*</Title>', page, 'title'), ' - Vidto')
|
2015-10-17 13:35:41 -04:00
|
|
|
|
2015-11-11 10:17:59 -05:00
|
|
|
hidden_fields = self._hidden_inputs(page)
|
2015-10-14 05:11:52 -04:00
|
|
|
|
2015-11-11 10:17:59 -05:00
|
|
|
self.to_screen('Waiting for countdown...')
|
2015-10-14 05:11:52 -04:00
|
|
|
time.sleep(7)
|
2015-11-11 10:17:59 -05:00
|
|
|
|
|
|
|
req = compat_urllib_request.Request(
|
|
|
|
url, urlencode_postdata(encode_dict(hidden_fields)))
|
|
|
|
req.add_header('Content-type', 'application/x-www-form-urlencoded')
|
|
|
|
|
2015-10-14 05:11:52 -04:00
|
|
|
post_result = self._download_webpage(
|
2015-10-17 13:35:41 -04:00
|
|
|
req, video_id,
|
2015-11-11 07:13:03 -05:00
|
|
|
note='Proceed to video...', errnote='unable to proceed')
|
2015-10-14 05:11:52 -04:00
|
|
|
|
2015-11-11 10:17:59 -05:00
|
|
|
file_link = self._search_regex(
|
|
|
|
r'file_link\s*=\s*\'(https?:\/\/[0-9a-zA-z.\/\-_]+)', post_result, 'file_link')
|
2015-10-14 05:11:52 -04:00
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'url': file_link,
|
|
|
|
'title': title,
|
|
|
|
}
|