2 from __future__ import unicode_literals
12 from .common import InfoExtractor
15 class SockshareIE(InfoExtractor):
16 _VALID_URL = r'https?://(?:www\.)?sockshare\.com/file/(?P<id>[0-9A-Za-z]+)'
17 _FILE_DELETED_REGEX = r'This file doesn\'t exist, or has been removed\.</div>'
19 'url': 'http://www.sockshare.com/file/437BE28B89D799D7',
20 'md5': '9d0bf1cfb6dbeaa8d562f6c97506c5bd',
22 'id': '437BE28B89D799D7',
23 'title': 'big_buck_bunny_720p_surround.avi',
25 'thumbnail': 're:^http://.*\.jpg$',
29 def _real_extract(self, url):
30 mobj = re.match(self._VALID_URL, url)
31 video_id = mobj.group('id')
33 url = 'http://sockshare.com/file/%s' % video_id
34 webpage = self._download_webpage(url, video_id)
36 if re.search(self._FILE_DELETED_REGEX, webpage) is not None:
37 raise ExtractorError('Video %s does not exist' % video_id,
40 confirm_hash = self._html_search_regex(r'''(?x)<input\s+
48 "confirm": "Continue as Free User"
51 post = compat_urllib_parse.urlencode(fields)
52 req = compat_urllib_request.Request(url, post)
53 # Apparently, this header is required for confirmation to work.
54 req.add_header('Host', 'www.sockshare.com')
55 req.add_header('Content-type', 'application/x-www-form-urlencoded')
57 webpage = self._download_webpage(
58 req, video_id, 'Downloading video page')
60 video_url = self._html_search_regex(
61 r'<a href="([^"]*)".+class="download_file_link"',
63 video_url = "http://www.sockshare.com" + video_url
64 title = self._html_search_regex((
66 r'var name = "([^"]+)";'),
67 webpage, 'title', default=None)
68 thumbnail = self._html_search_regex(
69 r'<img\s+src="([^"]*)".+?name="bg"',
75 'ext': determine_ext(title),
81 'thumbnail': thumbnail,