1 from __future__ import unicode_literals
6 from .common import InfoExtractor
8 compat_urllib_parse_urlparse,
17 class PornHubIE(InfoExtractor):
18 _VALID_URL = r'^(?:https?://)?(?:www\.)?(?P<url>pornhub\.com/view_video\.php\?viewkey=(?P<videoid>[0-9a-f]+))'
20 'url': 'http://www.pornhub.com/view_video.php?viewkey=648719015',
21 'file': '648719015.mp4',
22 'md5': '882f488fa1f0026f023f33576004a2ed',
24 "uploader": "BABES-COM",
25 "title": "Seductive Indian beauty strips down and fingers her pink pussy",
30 def _real_extract(self, url):
31 mobj = re.match(self._VALID_URL, url)
32 video_id = mobj.group('videoid')
33 url = 'http://www.' + mobj.group('url')
35 req = compat_urllib_request.Request(url)
36 req.add_header('Cookie', 'age_verified=1')
37 webpage = self._download_webpage(req, video_id)
39 video_title = self._html_search_regex(r'<h1 [^>]+>([^<]+)', webpage, 'title')
40 video_uploader = self._html_search_regex(r'<b>From: </b>(?:\s|<[^>]*>)*(.+?)<', webpage, 'uploader', fatal=False)
41 thumbnail = self._html_search_regex(r'"image_url":"([^"]+)', webpage, 'thumbnail', fatal=False)
43 thumbnail = compat_urllib_parse.unquote(thumbnail)
45 video_urls = list(map(compat_urllib_parse.unquote , re.findall(r'"quality_[0-9]{3}p":"([^"]+)', webpage)))
46 if webpage.find('"encrypted":true') != -1:
47 password = compat_urllib_parse.unquote_plus(self._html_search_regex(r'"video_title":"([^"]+)', webpage, 'password'))
48 video_urls = list(map(lambda s: aes_decrypt_text(s, password, 32).decode('utf-8'), video_urls))
51 for video_url in video_urls:
52 path = compat_urllib_parse_urlparse(video_url).path
53 extension = os.path.splitext(path)[1][1:]
54 format = path.split('/')[5].split('_')[:2]
55 format = "-".join(format)
57 m = re.match(r'^(?P<height>[0-9]+)P-(?P<tbr>[0-9]+)K$', format)
62 height = int(m.group('height'))
63 tbr = int(m.group('tbr'))
73 self._sort_formats(formats)
77 'uploader': video_uploader,
79 'thumbnail': thumbnail,