1 from __future__ import unicode_literals
6 from .common import InfoExtractor
15 class SharedIE(InfoExtractor):
16 _VALID_URL = r'http://shared\.sx/(?P<id>[\da-z]{10})'
19 'url': 'http://shared.sx/0060718775',
20 'md5': '106fefed92a8a2adb8c98e6a0652f49b',
28 def _real_extract(self, url):
29 mobj = re.match(self._VALID_URL, url)
30 video_id = mobj.group('id')
32 page = self._download_webpage(url, video_id)
34 if re.search(r'>File does not exist<', page) is not None:
35 raise ExtractorError('Video %s does not exist' % video_id, expected=True)
37 download_form = dict(re.findall(r'<input type="hidden" name="([^"]+)" value="([^"]*)"', page))
39 request = compat_urllib_request.Request(url, compat_urllib_parse.urlencode(download_form))
40 request.add_header('Content-Type', 'application/x-www-form-urlencoded')
42 video_page = self._download_webpage(request, video_id, 'Downloading video page')
44 video_url = self._html_search_regex(r'data-url="([^"]+)"', video_page, 'video URL')
45 title = base64.b64decode(self._html_search_meta('full:title', page, 'title')).decode('utf-8')
46 filesize = int_or_none(self._html_search_meta('full:size', page, 'file size', fatal=False))
47 thumbnail = self._html_search_regex(
48 r'data-poster="([^"]+)"', video_page, 'thumbnail', fatal=False, default=None)
56 'thumbnail': thumbnail,