Add PornHubPremium to pornhub.py
This commit is contained in:
parent
30c4a21f6e
commit
e9821a2423
@ -20,6 +20,7 @@ from ..utils import (
|
|||||||
orderedSet,
|
orderedSet,
|
||||||
remove_quotes,
|
remove_quotes,
|
||||||
str_to_int,
|
str_to_int,
|
||||||
|
urlencode_postdata,
|
||||||
url_or_none,
|
url_or_none,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -48,15 +49,39 @@ class PornHubBaseIE(InfoExtractor):
|
|||||||
|
|
||||||
class PornHubIE(PornHubBaseIE):
|
class PornHubIE(PornHubBaseIE):
|
||||||
IE_DESC = 'PornHub and Thumbzilla'
|
IE_DESC = 'PornHub and Thumbzilla'
|
||||||
|
_NETRC_MACHINE = 'pornhubpremium'
|
||||||
|
_LOGIN_URL = 'https://www.pornhubpremium.com/premium/login'
|
||||||
_VALID_URL = r'''(?x)
|
_VALID_URL = r'''(?x)
|
||||||
https?://
|
https?://
|
||||||
(?:
|
(?:
|
||||||
(?:[^/]+\.)?(?P<host>pornhub\.(?:com|net))/(?:(?:view_video\.php|video/show)\?viewkey=|embed/)|
|
(?:[^/]+\.)?(?P<host>(pornhub|pornhubpremium)\.(?:com|net))/(?:(?:view_video\.php|video/show)\?viewkey=|embed/)|
|
||||||
(?:www\.)?thumbzilla\.com/video/
|
(?:www\.)?thumbzilla\.com/video/
|
||||||
)
|
)
|
||||||
(?P<id>[\da-z]+)
|
(?P<id>[\da-z]+)
|
||||||
'''
|
'''
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
|
'url': 'https://fr.pornhubpremium.com/view_video.php?viewkey=ph5cd051fa7a6fc',
|
||||||
|
'md5': '42a65f5b095445ce2089954990fd7515',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'ph5cd051fa7a6fc',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Big Booty French Teen Dirty Young Slut',
|
||||||
|
'uploader': 'Porn Land Videos',
|
||||||
|
'upload_date': '20190506',
|
||||||
|
'duration': 1516,
|
||||||
|
'view_count': int,
|
||||||
|
'like_count': int,
|
||||||
|
'dislike_count': int,
|
||||||
|
'comment_count': int,
|
||||||
|
'age_limit': 18,
|
||||||
|
'tags': list,
|
||||||
|
'categories': list,
|
||||||
|
},
|
||||||
|
'params': {
|
||||||
|
'username': "",
|
||||||
|
'password': "",
|
||||||
|
},
|
||||||
|
}, {
|
||||||
'url': 'http://www.pornhub.com/view_video.php?viewkey=648719015',
|
'url': 'http://www.pornhub.com/view_video.php?viewkey=648719015',
|
||||||
'md5': '1e19b41231a02eba417839222ac9d58e',
|
'md5': '1e19b41231a02eba417839222ac9d58e',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
@ -160,6 +185,41 @@ class PornHubIE(PornHubBaseIE):
|
|||||||
return str_to_int(self._search_regex(
|
return str_to_int(self._search_regex(
|
||||||
pattern, webpage, '%s count' % name, fatal=False))
|
pattern, webpage, '%s count' % name, fatal=False))
|
||||||
|
|
||||||
|
def _login(self):
|
||||||
|
username, password = self._get_login_info()
|
||||||
|
if username is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
login_page = self._download_webpage(
|
||||||
|
self._LOGIN_URL, None, 'Downloading login page')
|
||||||
|
|
||||||
|
login_form = self._hidden_inputs(login_page)
|
||||||
|
|
||||||
|
login_form.update({
|
||||||
|
'username': username,
|
||||||
|
'password': password,
|
||||||
|
})
|
||||||
|
|
||||||
|
self._TOKEN = login_form['token']
|
||||||
|
|
||||||
|
response = self._download_json(
|
||||||
|
"https://www.pornhubpremium.com/front/authenticate", None, 'Logging in',
|
||||||
|
data=urlencode_postdata(login_form), headers={
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
'Referer': self._LOGIN_URL,
|
||||||
|
})
|
||||||
|
|
||||||
|
# Successful login
|
||||||
|
if response.get("success") == '1':
|
||||||
|
return
|
||||||
|
|
||||||
|
login_error = response.get("message")
|
||||||
|
if login_error:
|
||||||
|
raise ExtractorError(
|
||||||
|
'Unable to login: %s' % login_error, expected=True)
|
||||||
|
|
||||||
|
self.report_warning('Login has probably failed')
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
host = mobj.group('host') or 'pornhub.com'
|
host = mobj.group('host') or 'pornhub.com'
|
||||||
@ -332,6 +392,9 @@ class PornHubIE(PornHubBaseIE):
|
|||||||
'subtitles': subtitles,
|
'subtitles': subtitles,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _real_initialize(self):
|
||||||
|
self._login()
|
||||||
|
|
||||||
|
|
||||||
class PornHubPlaylistBaseIE(PornHubBaseIE):
|
class PornHubPlaylistBaseIE(PornHubBaseIE):
|
||||||
def _extract_entries(self, webpage, host):
|
def _extract_entries(self, webpage, host):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user