4 from .common
import InfoExtractor
6 compat_urllib_parse_urlparse
,
15 class PornHubIE(InfoExtractor
):
16 _VALID_URL
= r
'^(?:https?://)?(?:www\.)?(?P<url>pornhub\.com/view_video\.php\?viewkey=(?P<videoid>[0-9]+))'
18 u
'url': u
'http://www.pornhub.com/view_video.php?viewkey=648719015',
19 u
'file': u
'648719015.mp4',
20 u
'md5': u
'882f488fa1f0026f023f33576004a2ed',
22 u
"uploader": u
"BABES-COM",
23 u
"title": u
"Seductive Indian beauty strips down and fingers her pink pussy",
28 def _real_extract(self
, url
):
29 mobj
= re
.match(self
._VALID
_URL
, url
)
30 video_id
= mobj
.group('videoid')
31 url
= 'http://www.' + mobj
.group('url')
33 req
= compat_urllib_request
.Request(url
)
34 req
.add_header('Cookie', 'age_verified=1')
35 webpage
= self
._download
_webpage
(req
, video_id
)
37 video_title
= self
._html
_search
_regex
(r
'<h1 [^>]+>([^<]+)', webpage
, u
'title')
38 video_uploader
= self
._html
_search
_regex
(r
'<b>From: </b>(?:\s|<[^>]*>)*(.+?)<', webpage
, u
'uploader', fatal
=False)
39 thumbnail
= self
._html
_search
_regex
(r
'"image_url":"([^"]+)', webpage
, u
'thumbnail', fatal
=False)
41 thumbnail
= compat_urllib_parse
.unquote(thumbnail
)
43 video_urls
= list(map(compat_urllib_parse
.unquote
, re
.findall(r
'"quality_[0-9]{3}p":"([^"]+)', webpage
)))
44 if webpage
.find('"encrypted":true') != -1:
45 password
= self
._html
_search
_regex
(r
'"video_title":"([^"]+)', webpage
, u
'password').replace('+', ' ')
46 video_urls
= list(map(lambda s
: aes_decrypt_text(s
, password
, 32).decode('utf-8'), video_urls
))
49 for video_url
in video_urls
:
50 path
= compat_urllib_parse_urlparse( video_url
).path
51 extension
= os
.path
.splitext( path
)[1][1:]
52 format
= path
.split('/')[5].split('_')[:2]
53 format
= "-".join( format
)
60 formats
.sort(key
=lambda format
: list(map(lambda s
: s
.zfill(6), format
['format'].split('-'))))
64 'uploader': video_uploader
,
66 'thumbnail': thumbnail
,