2 from __future__ import unicode_literals
11 from .common import InfoExtractor
14 class SockshareIE(InfoExtractor):
15 _VALID_URL = r'https?://(?:www\.)?sockshare\.com/file/(?P<id>[0-9A-Za-z]+)'
16 _FILE_DELETED_REGEX = r'This file doesn\'t exist, or has been removed\.</div>'
18 'url': 'http://www.sockshare.com/file/437BE28B89D799D7',
19 'md5': '9d0bf1cfb6dbeaa8d562f6c97506c5bd',
21 'id': '437BE28B89D799D7',
22 'title': 'big_buck_bunny_720p_surround.avi',
24 'thumbnail': 're:^http://.*\.jpg$',
28 def _real_extract(self, url):
29 mobj = re.match(self._VALID_URL, url)
30 video_id = mobj.group('id')
32 url = 'http://sockshare.com/file/%s' % video_id
33 webpage = self._download_webpage(url, video_id)
35 if re.search(self._FILE_DELETED_REGEX, webpage) is not None:
36 raise ExtractorError('Video %s does not exist' % video_id,
39 confirm_hash = self._html_search_regex(r'''(?x)<input\s+
47 "confirm": "Continue as Free User"
50 post = compat_urllib_parse.urlencode(fields)
51 req = compat_urllib_request.Request(url, post)
52 # Apparently, this header is required for confirmation to work.
53 req.add_header('Host', 'www.sockshare.com')
54 req.add_header('Content-type', 'application/x-www-form-urlencoded')
56 webpage = self._download_webpage(
57 req, video_id, 'Downloading video page')
59 video_url = self._html_search_regex(
60 r'<a href="([^"]*)".+class="download_file_link"',
62 video_url = "http://www.sockshare.com" + video_url
63 title = self._html_search_regex(r'<h1>(.+)<strong>', webpage, 'title')
64 thumbnail = self._html_search_regex(
65 r'<img\s+src="([^"]*)".+?name="bg"',
76 'thumbnail': thumbnail,