2017-03-21 00:29:39 +01:00
|
|
|
import functools
|
2016-03-27 20:50:46 +02:00
|
|
|
import itertools
|
2021-08-15 19:32:48 +02:00
|
|
|
import math
|
2017-03-21 00:29:39 +01:00
|
|
|
import operator
|
2013-10-27 01:04:22 +02:00
|
|
|
import re
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2019-01-22 21:51:29 +01:00
|
|
|
from .openload import PhantomJSwrapper
|
2023-07-09 09:53:02 +02:00
|
|
|
from ..networking import Request
|
|
|
|
from ..networking.exceptions import HTTPError
|
2014-12-13 12:24:42 +01:00
|
|
|
from ..utils import (
|
2022-06-24 10:10:17 +02:00
|
|
|
NO_DEFAULT,
|
|
|
|
ExtractorError,
|
2021-06-13 18:06:47 +02:00
|
|
|
clean_html,
|
2019-03-22 19:09:33 +01:00
|
|
|
determine_ext,
|
2022-01-21 08:57:40 +01:00
|
|
|
format_field,
|
2016-02-19 16:42:46 +01:00
|
|
|
int_or_none,
|
2020-09-19 01:34:34 +02:00
|
|
|
merge_dicts,
|
2016-03-27 20:21:08 +02:00
|
|
|
orderedSet,
|
2017-03-21 19:59:27 +01:00
|
|
|
remove_quotes,
|
2022-06-18 17:06:12 +02:00
|
|
|
remove_start,
|
2014-03-22 15:29:01 +01:00
|
|
|
str_to_int,
|
2021-02-04 08:56:01 +01:00
|
|
|
update_url_query,
|
2018-07-29 01:24:10 +02:00
|
|
|
url_or_none,
|
2022-06-24 10:10:17 +02:00
|
|
|
urlencode_postdata,
|
2013-10-27 01:04:22 +02:00
|
|
|
)
|
|
|
|
|
2014-01-07 10:25:34 +01:00
|
|
|
|
2019-01-22 22:12:06 +01:00
|
|
|
class PornHubBaseIE(InfoExtractor):
|
2021-02-04 08:56:01 +01:00
|
|
|
_NETRC_MACHINE = 'pornhub'
|
2022-01-09 15:38:34 +01:00
|
|
|
_PORNHUB_HOST_RE = r'(?:(?P<host>pornhub(?:premium)?\.(?:com|net|org))|pornhubvybmsymdol4iibwgwtkpwmeyd6luq2gxajgjzfjvotyt5zhyd\.onion)'
|
2021-02-04 08:56:01 +01:00
|
|
|
|
2019-01-22 22:12:06 +01:00
|
|
|
def _download_webpage_handle(self, *args, **kwargs):
|
|
|
|
def dl(*args, **kwargs):
|
|
|
|
return super(PornHubBaseIE, self)._download_webpage_handle(*args, **kwargs)
|
|
|
|
|
2021-01-01 13:26:37 +01:00
|
|
|
ret = dl(*args, **kwargs)
|
|
|
|
|
|
|
|
if not ret:
|
|
|
|
return ret
|
|
|
|
|
|
|
|
webpage, urlh = ret
|
2019-01-22 22:12:06 +01:00
|
|
|
|
|
|
|
if any(re.search(p, webpage) for p in (
|
|
|
|
r'<body\b[^>]+\bonload=["\']go\(\)',
|
|
|
|
r'document\.cookie\s*=\s*["\']RNKEY=',
|
|
|
|
r'document\.location\.reload\(true\)')):
|
|
|
|
url_or_request = args[0]
|
2023-07-09 09:53:02 +02:00
|
|
|
url = (url_or_request.url
|
|
|
|
if isinstance(url_or_request, Request)
|
2019-01-22 22:12:06 +01:00
|
|
|
else url_or_request)
|
|
|
|
phantom = PhantomJSwrapper(self, required_version='2.0')
|
|
|
|
phantom.get(url, html=webpage)
|
|
|
|
webpage, urlh = dl(*args, **kwargs)
|
|
|
|
|
|
|
|
return webpage, urlh
|
|
|
|
|
2021-02-04 08:56:01 +01:00
|
|
|
def _real_initialize(self):
|
|
|
|
self._logged_in = False
|
|
|
|
|
2023-04-25 22:46:14 +02:00
|
|
|
def _set_age_cookies(self, host):
|
|
|
|
self._set_cookie(host, 'age_verified', '1')
|
|
|
|
self._set_cookie(host, 'accessAgeDisclaimerPH', '1')
|
2023-07-15 22:54:19 +02:00
|
|
|
self._set_cookie(host, 'accessAgeDisclaimerUK', '1')
|
2023-04-25 22:46:14 +02:00
|
|
|
self._set_cookie(host, 'accessPH', '1')
|
|
|
|
|
2021-02-04 08:56:01 +01:00
|
|
|
def _login(self, host):
|
|
|
|
if self._logged_in:
|
|
|
|
return
|
|
|
|
|
|
|
|
site = host.split('.')[0]
|
|
|
|
|
|
|
|
# Both sites pornhub and pornhubpremium have separate accounts
|
|
|
|
# so there should be an option to provide credentials for both.
|
|
|
|
# At the same time some videos are available under the same video id
|
|
|
|
# on both sites so that we have to identify them as the same video.
|
|
|
|
# For that purpose we have to keep both in the same extractor
|
|
|
|
# but under different netrc machines.
|
|
|
|
username, password = self._get_login_info(netrc_machine=site)
|
|
|
|
if username is None:
|
|
|
|
return
|
|
|
|
|
2024-06-12 01:09:58 +02:00
|
|
|
login_url = 'https://www.{}/{}login'.format(host, 'premium/' if 'premium' in host else '')
|
2021-02-04 08:56:01 +01:00
|
|
|
login_page = self._download_webpage(
|
2024-06-12 01:09:58 +02:00
|
|
|
login_url, None, f'Downloading {site} login page')
|
2021-02-04 08:56:01 +01:00
|
|
|
|
|
|
|
def is_logged(webpage):
|
|
|
|
return any(re.search(p, webpage) for p in (
|
2024-02-17 23:46:05 +01:00
|
|
|
r'id="profileMenuDropdown"',
|
|
|
|
r'class="ph-icon-logout"'))
|
2021-02-04 08:56:01 +01:00
|
|
|
|
|
|
|
if is_logged(login_page):
|
|
|
|
self._logged_in = True
|
|
|
|
return
|
|
|
|
|
|
|
|
login_form = self._hidden_inputs(login_page)
|
|
|
|
|
|
|
|
login_form.update({
|
2024-05-14 01:18:14 +02:00
|
|
|
'email': username,
|
2021-02-04 08:56:01 +01:00
|
|
|
'password': password,
|
|
|
|
})
|
|
|
|
|
|
|
|
response = self._download_json(
|
2024-06-12 01:09:58 +02:00
|
|
|
f'https://www.{host}/front/authenticate', None,
|
|
|
|
f'Logging in to {site}',
|
2021-02-04 08:56:01 +01:00
|
|
|
data=urlencode_postdata(login_form),
|
|
|
|
headers={
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
|
|
|
'Referer': login_url,
|
|
|
|
'X-Requested-With': 'XMLHttpRequest',
|
|
|
|
})
|
|
|
|
|
|
|
|
if response.get('success') == '1':
|
|
|
|
self._logged_in = True
|
|
|
|
return
|
|
|
|
|
|
|
|
message = response.get('message')
|
|
|
|
if message is not None:
|
|
|
|
raise ExtractorError(
|
2024-06-12 01:09:58 +02:00
|
|
|
f'Unable to login: {message}', expected=True)
|
2021-02-04 08:56:01 +01:00
|
|
|
|
|
|
|
raise ExtractorError('Unable to log in')
|
|
|
|
|
2019-01-22 22:12:06 +01:00
|
|
|
|
|
|
|
class PornHubIE(PornHubBaseIE):
|
2016-07-01 21:11:07 +02:00
|
|
|
IE_DESC = 'PornHub and Thumbzilla'
|
2024-06-12 01:09:58 +02:00
|
|
|
_VALID_URL = rf'''(?x)
|
2016-07-01 21:11:07 +02:00
|
|
|
https?://
|
|
|
|
(?:
|
2021-06-23 03:26:37 +02:00
|
|
|
(?:[^/]+\.)?
|
2024-06-12 01:09:58 +02:00
|
|
|
{PornHubBaseIE._PORNHUB_HOST_RE}
|
2021-06-23 03:26:37 +02:00
|
|
|
/(?:(?:view_video\.php|video/show)\?viewkey=|embed/)|
|
2016-07-01 21:11:07 +02:00
|
|
|
(?:www\.)?thumbzilla\.com/video/
|
|
|
|
)
|
2016-11-06 15:52:00 +01:00
|
|
|
(?P<id>[\da-z]+)
|
2024-06-12 01:09:58 +02:00
|
|
|
'''
|
2022-08-01 03:23:25 +02:00
|
|
|
_EMBED_REGEX = [r'<iframe[^>]+?src=["\'](?P<url>(?:https?:)?//(?:www\.)?pornhub(?:premium)?\.(?:com|net|org)/embed/[\da-z]+)']
|
2015-06-18 18:26:17 +02:00
|
|
|
_TESTS = [{
|
2014-01-07 10:25:34 +01:00
|
|
|
'url': 'http://www.pornhub.com/view_video.php?viewkey=648719015',
|
2020-09-19 01:34:34 +02:00
|
|
|
'md5': 'a6391306d050e4547f62b3f485dd9ba9',
|
2014-01-07 10:25:34 +01:00
|
|
|
'info_dict': {
|
2014-10-27 00:33:35 +01:00
|
|
|
'id': '648719015',
|
|
|
|
'ext': 'mp4',
|
2016-02-14 10:37:17 +01:00
|
|
|
'title': 'Seductive Indian beauty strips down and fingers her pink pussy',
|
2016-02-19 16:42:46 +01:00
|
|
|
'uploader': 'Babes',
|
2018-09-14 21:04:43 +02:00
|
|
|
'upload_date': '20130628',
|
2020-09-19 01:34:34 +02:00
|
|
|
'timestamp': 1372447216,
|
2016-02-19 16:42:46 +01:00
|
|
|
'duration': 361,
|
|
|
|
'view_count': int,
|
|
|
|
'like_count': int,
|
|
|
|
'dislike_count': int,
|
|
|
|
'comment_count': int,
|
|
|
|
'age_limit': 18,
|
2016-09-11 13:22:51 +02:00
|
|
|
'tags': list,
|
|
|
|
'categories': list,
|
2021-06-13 18:06:47 +02:00
|
|
|
'cast': list,
|
2016-06-13 23:57:59 +02:00
|
|
|
},
|
|
|
|
}, {
|
|
|
|
# non-ASCII title
|
|
|
|
'url': 'http://www.pornhub.com/view_video.php?viewkey=1331683002',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '1331683002',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': '重庆婷婷女王足交',
|
2018-09-14 21:04:43 +02:00
|
|
|
'upload_date': '20150213',
|
2020-09-19 01:34:34 +02:00
|
|
|
'timestamp': 1423804862,
|
2016-06-13 23:57:59 +02:00
|
|
|
'duration': 1753,
|
|
|
|
'view_count': int,
|
|
|
|
'like_count': int,
|
|
|
|
'dislike_count': int,
|
|
|
|
'comment_count': int,
|
|
|
|
'age_limit': 18,
|
2016-09-11 13:22:51 +02:00
|
|
|
'tags': list,
|
|
|
|
'categories': list,
|
2016-06-13 23:57:59 +02:00
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
2021-03-15 00:22:06 +01:00
|
|
|
'skip': 'Video has been flagged for verification in accordance with our trust and safety policy',
|
2018-07-29 01:24:10 +02:00
|
|
|
}, {
|
|
|
|
# subtitles
|
|
|
|
'url': 'https://www.pornhub.com/view_video.php?viewkey=ph5af5fef7c2aa7',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'ph5af5fef7c2aa7',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'BFFS - Cute Teen Girls Share Cock On the Floor',
|
|
|
|
'uploader': 'BFFs',
|
|
|
|
'duration': 622,
|
|
|
|
'view_count': int,
|
|
|
|
'like_count': int,
|
|
|
|
'dislike_count': int,
|
|
|
|
'comment_count': int,
|
|
|
|
'age_limit': 18,
|
|
|
|
'tags': list,
|
|
|
|
'categories': list,
|
|
|
|
'subtitles': {
|
|
|
|
'en': [{
|
2024-06-12 01:09:58 +02:00
|
|
|
'ext': 'srt',
|
|
|
|
}],
|
2018-07-29 01:24:10 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
2020-09-19 01:34:34 +02:00
|
|
|
'skip': 'This video has been disabled',
|
2022-06-18 17:06:12 +02:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.pornhub.com/view_video.php?viewkey=ph601dc30bae19a',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'ph601dc30bae19a',
|
|
|
|
'uploader': 'Projekt Melody',
|
|
|
|
'uploader_id': 'projekt-melody',
|
|
|
|
'upload_date': '20210205',
|
|
|
|
'title': '"Welcome to My Pussy Mansion" - CB Stream (02/03/21)',
|
|
|
|
'thumbnail': r're:https?://.+',
|
|
|
|
},
|
2015-06-18 18:26:17 +02:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.pornhub.com/view_video.php?viewkey=ph557bbb6676d2d',
|
|
|
|
'only_matching': True,
|
2015-09-15 17:24:01 +02:00
|
|
|
}, {
|
2016-06-30 22:18:27 +02:00
|
|
|
# removed at the request of cam4.com
|
2015-09-15 17:24:01 +02:00
|
|
|
'url': 'http://fr.pornhub.com/view_video.php?viewkey=ph55ca2f9760862',
|
|
|
|
'only_matching': True,
|
2016-06-30 22:18:27 +02:00
|
|
|
}, {
|
|
|
|
# removed at the request of the copyright owner
|
|
|
|
'url': 'http://www.pornhub.com/view_video.php?viewkey=788152859',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
# removed by uploader
|
|
|
|
'url': 'http://www.pornhub.com/view_video.php?viewkey=ph572716d15a111',
|
|
|
|
'only_matching': True,
|
2016-07-03 22:27:00 +02:00
|
|
|
}, {
|
|
|
|
# private video
|
|
|
|
'url': 'http://www.pornhub.com/view_video.php?viewkey=ph56fd731fce6b7',
|
|
|
|
'only_matching': True,
|
2016-07-01 21:11:07 +02:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.thumbzilla.com/video/ph56c6114abd99a/horny-girlfriend-sex',
|
|
|
|
'only_matching': True,
|
2017-05-05 21:46:37 +02:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.pornhub.com/video/show?viewkey=648719015',
|
|
|
|
'only_matching': True,
|
2018-11-18 05:14:46 +01:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.net/view_video.php?viewkey=203640933',
|
|
|
|
'only_matching': True,
|
2021-01-01 13:26:37 +01:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.org/view_video.php?viewkey=203640933',
|
|
|
|
'only_matching': True,
|
2020-03-08 12:00:25 +01:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhubpremium.com/view_video.php?viewkey=ph5e4acdae54a82',
|
|
|
|
'only_matching': True,
|
2021-02-04 08:56:01 +01:00
|
|
|
}, {
|
|
|
|
# Some videos are available with the same id on both premium
|
|
|
|
# and non-premium sites (e.g. this and the following test)
|
|
|
|
'url': 'https://www.pornhub.com/view_video.php?viewkey=ph5f75b0f4b18e3',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhubpremium.com/view_video.php?viewkey=ph5f75b0f4b18e3',
|
|
|
|
'only_matching': True,
|
2021-06-23 03:26:37 +02:00
|
|
|
}, {
|
|
|
|
# geo restricted
|
|
|
|
'url': 'https://www.pornhub.com/view_video.php?viewkey=ph5a9813bfa7156',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
2022-01-09 15:38:34 +01:00
|
|
|
'url': 'http://pornhubvybmsymdol4iibwgwtkpwmeyd6luq2gxajgjzfjvotyt5zhyd.onion/view_video.php?viewkey=ph5a9813bfa7156',
|
2021-06-23 03:26:37 +02:00
|
|
|
'only_matching': True,
|
2015-06-18 18:26:17 +02:00
|
|
|
}]
|
2013-10-27 01:04:22 +02:00
|
|
|
|
2014-03-22 15:29:01 +01:00
|
|
|
def _extract_count(self, pattern, webpage, name):
|
2024-06-12 01:09:58 +02:00
|
|
|
return str_to_int(self._search_regex(pattern, webpage, f'{name} count', default=None))
|
2014-03-22 15:29:01 +01:00
|
|
|
|
2013-10-27 01:04:22 +02:00
|
|
|
def _real_extract(self, url):
|
2021-08-19 03:41:24 +02:00
|
|
|
mobj = self._match_valid_url(url)
|
2018-12-01 10:45:51 +01:00
|
|
|
host = mobj.group('host') or 'pornhub.com'
|
|
|
|
video_id = mobj.group('id')
|
2018-03-10 17:14:16 +01:00
|
|
|
|
2021-02-04 08:56:01 +01:00
|
|
|
self._login(host)
|
2023-04-25 22:46:14 +02:00
|
|
|
self._set_age_cookies(host)
|
2013-10-27 01:04:22 +02:00
|
|
|
|
2017-02-14 17:52:41 +01:00
|
|
|
def dl_webpage(platform):
|
2018-12-01 10:45:51 +01:00
|
|
|
self._set_cookie(host, 'platform', platform)
|
2017-02-14 17:52:41 +01:00
|
|
|
return self._download_webpage(
|
2024-06-12 01:09:58 +02:00
|
|
|
f'https://www.{host}/view_video.php?viewkey={video_id}',
|
|
|
|
video_id, f'Downloading {platform} webpage')
|
2017-02-14 17:52:41 +01:00
|
|
|
|
|
|
|
webpage = dl_webpage('pc')
|
2013-10-27 01:04:22 +02:00
|
|
|
|
2015-01-22 23:48:58 +01:00
|
|
|
error_msg = self._html_search_regex(
|
2021-03-15 00:22:06 +01:00
|
|
|
(r'(?s)<div[^>]+class=(["\'])(?:(?!\1).)*\b(?:removed|userMessageSection)\b(?:(?!\1).)*\1[^>]*>(?P<error>.+?)</div>',
|
|
|
|
r'(?s)<section[^>]+class=["\']noVideo["\'][^>]*>(?P<error>.+?)</section>'),
|
2016-06-30 22:14:23 +02:00
|
|
|
webpage, 'error message', default=None, group='error')
|
2015-01-22 23:48:58 +01:00
|
|
|
if error_msg:
|
|
|
|
error_msg = re.sub(r'\s+', ' ', error_msg)
|
|
|
|
raise ExtractorError(
|
2024-06-12 01:09:58 +02:00
|
|
|
f'PornHub said: {error_msg}',
|
2015-01-22 23:48:58 +01:00
|
|
|
expected=True, video_id=video_id)
|
|
|
|
|
2021-06-23 03:26:37 +02:00
|
|
|
if any(re.search(p, webpage) for p in (
|
|
|
|
r'class=["\']geoBlocked["\']',
|
|
|
|
r'>\s*This content is unavailable in your country')):
|
|
|
|
self.raise_geo_restricted()
|
|
|
|
|
2016-06-13 23:57:59 +02:00
|
|
|
# video_title from flashvars contains whitespace instead of non-ASCII (see
|
|
|
|
# http://www.pornhub.com/view_video.php?viewkey=1331683002), not relying
|
|
|
|
# on that anymore.
|
2018-07-14 13:05:06 +02:00
|
|
|
title = self._html_search_meta(
|
2020-03-03 00:23:39 +01:00
|
|
|
'twitter:title', webpage, default=None) or self._html_search_regex(
|
|
|
|
(r'(?s)<h1[^>]+class=["\']title["\'][^>]*>(?P<title>.+?)</h1>',
|
|
|
|
r'<div[^>]+data-video-title=(["\'])(?P<title>(?:(?!\1).)+)\1',
|
|
|
|
r'shareTitle["\']\s*[=:]\s*(["\'])(?P<title>(?:(?!\1).)+)\1'),
|
2016-06-13 23:57:59 +02:00
|
|
|
webpage, 'title', group='title')
|
|
|
|
|
2018-07-14 13:05:06 +02:00
|
|
|
video_urls = []
|
|
|
|
video_urls_set = set()
|
2018-07-29 01:24:10 +02:00
|
|
|
subtitles = {}
|
2018-07-14 13:05:06 +02:00
|
|
|
|
2016-02-19 16:42:46 +01:00
|
|
|
flashvars = self._parse_json(
|
|
|
|
self._search_regex(
|
2016-03-27 21:21:44 +02:00
|
|
|
r'var\s+flashvars_\d+\s*=\s*({.+?});', webpage, 'flashvars', default='{}'),
|
2016-02-19 16:42:46 +01:00
|
|
|
video_id)
|
|
|
|
if flashvars:
|
2018-07-29 01:24:10 +02:00
|
|
|
subtitle_url = url_or_none(flashvars.get('closedCaptionsFile'))
|
|
|
|
if subtitle_url:
|
|
|
|
subtitles.setdefault('en', []).append({
|
|
|
|
'url': subtitle_url,
|
|
|
|
'ext': 'srt',
|
|
|
|
})
|
2016-02-19 16:42:46 +01:00
|
|
|
thumbnail = flashvars.get('image_url')
|
|
|
|
duration = int_or_none(flashvars.get('video_duration'))
|
2018-07-14 13:05:06 +02:00
|
|
|
media_definitions = flashvars.get('mediaDefinitions')
|
|
|
|
if isinstance(media_definitions, list):
|
|
|
|
for definition in media_definitions:
|
|
|
|
if not isinstance(definition, dict):
|
|
|
|
continue
|
|
|
|
video_url = definition.get('videoUrl')
|
2024-06-12 01:09:58 +02:00
|
|
|
if not video_url or not isinstance(video_url, str):
|
2018-07-14 13:05:06 +02:00
|
|
|
continue
|
|
|
|
if video_url in video_urls_set:
|
|
|
|
continue
|
|
|
|
video_urls_set.add(video_url)
|
|
|
|
video_urls.append(
|
|
|
|
(video_url, int_or_none(definition.get('quality'))))
|
2016-02-19 16:42:46 +01:00
|
|
|
else:
|
2018-07-14 13:05:06 +02:00
|
|
|
thumbnail, duration = [None] * 2
|
|
|
|
|
2019-12-31 17:43:43 +01:00
|
|
|
def extract_js_vars(webpage, pattern, default=NO_DEFAULT):
|
2018-07-14 13:05:06 +02:00
|
|
|
assignments = self._search_regex(
|
2019-12-31 17:43:43 +01:00
|
|
|
pattern, webpage, 'encoded url', default=default)
|
2019-12-31 17:29:06 +01:00
|
|
|
if not assignments:
|
|
|
|
return {}
|
|
|
|
|
|
|
|
assignments = assignments.split(';')
|
2018-07-14 13:05:06 +02:00
|
|
|
|
|
|
|
js_vars = {}
|
|
|
|
|
|
|
|
def parse_js_value(inp):
|
|
|
|
inp = re.sub(r'/\*(?:(?!\*/).)*?\*/', '', inp)
|
|
|
|
if '+' in inp:
|
|
|
|
inps = inp.split('+')
|
|
|
|
return functools.reduce(
|
|
|
|
operator.concat, map(parse_js_value, inps))
|
|
|
|
inp = inp.strip()
|
|
|
|
if inp in js_vars:
|
|
|
|
return js_vars[inp]
|
|
|
|
return remove_quotes(inp)
|
|
|
|
|
|
|
|
for assn in assignments:
|
|
|
|
assn = assn.strip()
|
|
|
|
if not assn:
|
|
|
|
continue
|
|
|
|
assn = re.sub(r'var\s+', '', assn)
|
|
|
|
vname, value = assn.split('=', 1)
|
|
|
|
js_vars[vname] = parse_js_value(value)
|
2019-12-31 17:29:06 +01:00
|
|
|
return js_vars
|
2018-07-14 13:05:06 +02:00
|
|
|
|
2019-12-31 17:29:06 +01:00
|
|
|
def add_video_url(video_url):
|
|
|
|
v_url = url_or_none(video_url)
|
|
|
|
if not v_url:
|
|
|
|
return
|
|
|
|
if v_url in video_urls_set:
|
|
|
|
return
|
|
|
|
video_urls.append((v_url, None))
|
|
|
|
video_urls_set.add(v_url)
|
|
|
|
|
2021-01-01 13:26:37 +01:00
|
|
|
def parse_quality_items(quality_items):
|
|
|
|
q_items = self._parse_json(quality_items, video_id, fatal=False)
|
|
|
|
if not isinstance(q_items, list):
|
|
|
|
return
|
|
|
|
for item in q_items:
|
|
|
|
if isinstance(item, dict):
|
|
|
|
add_video_url(item.get('url'))
|
|
|
|
|
2019-12-31 17:29:06 +01:00
|
|
|
if not video_urls:
|
2021-01-01 13:26:37 +01:00
|
|
|
FORMAT_PREFIXES = ('media', 'quality', 'qualityItems')
|
2019-12-31 17:29:06 +01:00
|
|
|
js_vars = extract_js_vars(
|
2024-06-12 01:09:58 +02:00
|
|
|
webpage, r'(var\s+(?:{})_.+)'.format('|'.join(FORMAT_PREFIXES)),
|
2019-12-31 17:43:43 +01:00
|
|
|
default=None)
|
2019-12-31 17:29:06 +01:00
|
|
|
if js_vars:
|
|
|
|
for key, format_url in js_vars.items():
|
2021-01-01 13:26:37 +01:00
|
|
|
if key.startswith(FORMAT_PREFIXES[-1]):
|
|
|
|
parse_quality_items(format_url)
|
|
|
|
elif any(key.startswith(p) for p in FORMAT_PREFIXES[:2]):
|
2019-12-31 17:29:06 +01:00
|
|
|
add_video_url(format_url)
|
2019-12-31 17:43:43 +01:00
|
|
|
if not video_urls and re.search(
|
|
|
|
r'<[^>]+\bid=["\']lockedPlayer', webpage):
|
|
|
|
raise ExtractorError(
|
2024-06-12 01:09:58 +02:00
|
|
|
f'Video {video_id} is locked', expected=True)
|
2019-12-31 17:29:06 +01:00
|
|
|
|
|
|
|
if not video_urls:
|
|
|
|
js_vars = extract_js_vars(
|
|
|
|
dl_webpage('tv'), r'(var.+?mediastring.+?)</script>')
|
|
|
|
add_video_url(js_vars['mediastring'])
|
2018-07-14 13:05:06 +02:00
|
|
|
|
|
|
|
for mobj in re.finditer(
|
|
|
|
r'<a[^>]+\bclass=["\']downloadBtn\b[^>]+\bhref=(["\'])(?P<url>(?:(?!\1).)+)\1',
|
|
|
|
webpage):
|
|
|
|
video_url = mobj.group('url')
|
|
|
|
if video_url not in video_urls_set:
|
|
|
|
video_urls.append((video_url, None))
|
|
|
|
video_urls_set.add(video_url)
|
|
|
|
|
2018-09-14 21:04:43 +02:00
|
|
|
upload_date = None
|
2018-07-14 13:05:06 +02:00
|
|
|
formats = []
|
2021-03-15 00:22:06 +01:00
|
|
|
|
|
|
|
def add_format(format_url, height=None):
|
2021-04-10 18:47:11 +02:00
|
|
|
ext = determine_ext(format_url)
|
|
|
|
if ext == 'mpd':
|
|
|
|
formats.extend(self._extract_mpd_formats(
|
|
|
|
format_url, video_id, mpd_id='dash', fatal=False))
|
|
|
|
return
|
|
|
|
if ext == 'm3u8':
|
|
|
|
formats.extend(self._extract_m3u8_formats(
|
|
|
|
format_url, video_id, 'mp4', entry_protocol='m3u8_native',
|
|
|
|
m3u8_id='hls', fatal=False))
|
|
|
|
return
|
2021-06-23 03:26:37 +02:00
|
|
|
if not height:
|
|
|
|
height = int_or_none(self._search_regex(
|
|
|
|
r'(?P<height>\d+)[pP]?_\d+[kK]', format_url, 'height',
|
|
|
|
default=None))
|
2021-03-15 00:22:06 +01:00
|
|
|
formats.append({
|
|
|
|
'url': format_url,
|
2022-06-18 04:00:12 +02:00
|
|
|
'format_id': format_field(height, None, '%dp'),
|
2021-03-15 00:22:06 +01:00
|
|
|
'height': height,
|
|
|
|
})
|
|
|
|
|
2018-07-14 13:05:06 +02:00
|
|
|
for video_url, height in video_urls:
|
2018-09-14 21:04:43 +02:00
|
|
|
if not upload_date:
|
|
|
|
upload_date = self._search_regex(
|
|
|
|
r'/(\d{6}/\d{2})/', video_url, 'upload data', default=None)
|
|
|
|
if upload_date:
|
|
|
|
upload_date = upload_date.replace('/', '')
|
2021-03-15 00:22:06 +01:00
|
|
|
if '/video/get_media' in video_url:
|
|
|
|
medias = self._download_json(video_url, video_id, fatal=False)
|
|
|
|
if isinstance(medias, list):
|
|
|
|
for media in medias:
|
|
|
|
if not isinstance(media, dict):
|
|
|
|
continue
|
|
|
|
video_url = url_or_none(media.get('videoUrl'))
|
|
|
|
if not video_url:
|
|
|
|
continue
|
|
|
|
height = int_or_none(media.get('quality'))
|
|
|
|
add_format(video_url, height)
|
|
|
|
continue
|
|
|
|
add_format(video_url)
|
2021-06-23 03:26:37 +02:00
|
|
|
|
2022-06-18 17:06:12 +02:00
|
|
|
model_profile = self._search_json(
|
|
|
|
r'var\s+MODEL_PROFILE\s*=', webpage, 'model profile', video_id, fatal=False)
|
2014-03-22 15:29:01 +01:00
|
|
|
video_uploader = self._html_search_regex(
|
2018-09-05 19:51:20 +02:00
|
|
|
r'(?s)From: .+?<(?:a\b[^>]+\bhref=["\']/(?:(?:user|channel)s|model|pornstar)/|span\b[^>]+\bclass=["\']username)[^>]+>(.+?)<',
|
2022-06-18 17:06:12 +02:00
|
|
|
webpage, 'uploader', default=None) or model_profile.get('username')
|
2013-10-27 01:04:22 +02:00
|
|
|
|
2021-01-01 13:26:37 +01:00
|
|
|
def extract_vote_count(kind, name):
|
|
|
|
return self._extract_count(
|
2024-06-12 01:09:58 +02:00
|
|
|
(rf'<span[^>]+\bclass="votes{kind}"[^>]*>([\d,\.]+)</span>',
|
|
|
|
rf'<span[^>]+\bclass=["\']votes{kind}["\'][^>]*\bdata-rating=["\'](\d+)'),
|
2021-01-01 13:26:37 +01:00
|
|
|
webpage, name)
|
|
|
|
|
2015-03-30 15:41:04 +02:00
|
|
|
view_count = self._extract_count(
|
2020-09-19 00:59:19 +02:00
|
|
|
r'<span class="count">([\d,\.]+)</span> [Vv]iews', webpage, 'view')
|
2021-01-01 13:26:37 +01:00
|
|
|
like_count = extract_vote_count('Up', 'like')
|
|
|
|
dislike_count = extract_vote_count('Down', 'dislike')
|
2014-03-22 15:29:01 +01:00
|
|
|
comment_count = self._extract_count(
|
2015-03-30 15:41:04 +02:00
|
|
|
r'All Comments\s*<span>\(([\d,.]+)\)', webpage, 'comment')
|
2014-03-22 15:29:01 +01:00
|
|
|
|
2019-02-05 17:06:55 +01:00
|
|
|
def extract_list(meta_key):
|
2019-02-04 18:33:54 +01:00
|
|
|
div = self._search_regex(
|
2024-06-12 01:09:58 +02:00
|
|
|
rf'(?s)<div[^>]+\bclass=["\'].*?\b{meta_key}Wrapper[^>]*>(.+?)</div>',
|
|
|
|
webpage, meta_key, default=None)
|
2019-02-04 18:33:54 +01:00
|
|
|
if div:
|
2021-06-13 18:06:47 +02:00
|
|
|
return [clean_html(x).strip() for x in re.findall(r'(?s)<a[^>]+\bhref=[^>]+>.+?</a>', div)]
|
2016-09-11 13:22:51 +02:00
|
|
|
|
2020-09-19 01:34:34 +02:00
|
|
|
info = self._search_json_ld(webpage, video_id, default={})
|
|
|
|
# description provided in JSON-LD is irrelevant
|
|
|
|
info['description'] = None
|
|
|
|
|
|
|
|
return merge_dicts({
|
2013-10-27 01:04:22 +02:00
|
|
|
'id': video_id,
|
|
|
|
'uploader': video_uploader,
|
2022-06-18 17:06:12 +02:00
|
|
|
'uploader_id': remove_start(model_profile.get('modelProfileLink'), '/model/'),
|
2018-09-14 21:04:43 +02:00
|
|
|
'upload_date': upload_date,
|
2016-06-13 23:57:59 +02:00
|
|
|
'title': title,
|
2013-10-27 01:04:22 +02:00
|
|
|
'thumbnail': thumbnail,
|
2016-02-19 16:42:46 +01:00
|
|
|
'duration': duration,
|
2014-03-22 15:29:01 +01:00
|
|
|
'view_count': view_count,
|
|
|
|
'like_count': like_count,
|
|
|
|
'dislike_count': dislike_count,
|
|
|
|
'comment_count': comment_count,
|
2018-07-14 13:05:06 +02:00
|
|
|
'formats': formats,
|
2013-10-28 06:50:17 +01:00
|
|
|
'age_limit': 18,
|
2019-02-05 17:06:55 +01:00
|
|
|
'tags': extract_list('tags'),
|
|
|
|
'categories': extract_list('categories'),
|
2021-06-13 18:06:47 +02:00
|
|
|
'cast': extract_list('pornstars'),
|
2018-07-29 01:24:10 +02:00
|
|
|
'subtitles': subtitles,
|
2020-09-19 01:34:34 +02:00
|
|
|
}, info)
|
2015-02-19 17:15:19 +01:00
|
|
|
|
|
|
|
|
2019-01-22 22:12:06 +01:00
|
|
|
class PornHubPlaylistBaseIE(PornHubBaseIE):
|
2021-02-04 08:56:01 +01:00
|
|
|
def _extract_page(self, url):
|
|
|
|
return int_or_none(self._search_regex(
|
|
|
|
r'\bpage=(\d+)', url, 'page', default=None))
|
|
|
|
|
2018-12-01 10:45:51 +01:00
|
|
|
def _extract_entries(self, webpage, host):
|
2017-08-13 02:53:02 +02:00
|
|
|
# Only process container div with main playlist content skipping
|
|
|
|
# drop-down menu that uses similar pattern for videos (see
|
2019-03-09 13:14:41 +01:00
|
|
|
# https://github.com/ytdl-org/youtube-dl/issues/11594).
|
2017-08-13 02:53:02 +02:00
|
|
|
container = self._search_regex(
|
|
|
|
r'(?s)(<div[^>]+class=["\']container.+)', webpage,
|
|
|
|
'container', default=webpage)
|
|
|
|
|
2016-02-18 17:29:17 +01:00
|
|
|
return [
|
2016-03-27 20:32:57 +02:00
|
|
|
self.url_result(
|
2024-06-12 01:09:58 +02:00
|
|
|
f'http://www.{host}/{video_url}',
|
2016-03-27 20:32:57 +02:00
|
|
|
PornHubIE.ie_key(), video_title=title)
|
|
|
|
for video_url, title in orderedSet(re.findall(
|
|
|
|
r'href="/?(view_video\.php\?.*\bviewkey=[\da-z]+[^"]*)"[^>]*\s+title="([^"]+)"',
|
2017-08-13 02:53:02 +02:00
|
|
|
container))
|
2016-02-18 17:29:17 +01:00
|
|
|
]
|
2015-02-19 17:15:19 +01:00
|
|
|
|
2016-02-18 17:29:17 +01:00
|
|
|
|
2019-06-22 00:34:46 +02:00
|
|
|
class PornHubUserIE(PornHubPlaylistBaseIE):
|
2024-06-12 01:09:58 +02:00
|
|
|
_VALID_URL = rf'(?P<url>https?://(?:[^/]+\.)?{PornHubBaseIE._PORNHUB_HOST_RE}/(?:(?:user|channel)s|model|pornstar)/(?P<id>[^/?#&]+))(?:[?#&]|/(?!videos)|$)'
|
2016-02-18 17:29:17 +01:00
|
|
|
_TESTS = [{
|
2019-06-22 00:34:46 +02:00
|
|
|
'url': 'https://www.pornhub.com/model/zoe_ph',
|
|
|
|
'playlist_mincount': 118,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/pornstar/liz-vicious',
|
2016-02-18 17:29:17 +01:00
|
|
|
'info_dict': {
|
2019-06-22 00:34:46 +02:00
|
|
|
'id': 'liz-vicious',
|
2016-02-18 17:29:17 +01:00
|
|
|
},
|
2019-06-22 00:34:46 +02:00
|
|
|
'playlist_mincount': 118,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/users/russianveet69',
|
2019-06-22 03:37:07 +02:00
|
|
|
'only_matching': True,
|
2019-06-22 00:34:46 +02:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/channels/povd',
|
2019-06-22 03:37:07 +02:00
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/model/zoe_ph?abc=1',
|
|
|
|
'only_matching': True,
|
2021-02-04 08:56:01 +01:00
|
|
|
}, {
|
|
|
|
# Unavailable via /videos page, but available with direct pagination
|
|
|
|
# on pornstar page (see [1]), requires premium
|
|
|
|
# 1. https://github.com/ytdl-org/youtube-dl/issues/27853
|
|
|
|
'url': 'https://www.pornhubpremium.com/pornstar/sienna-west',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
# Same as before, multi page
|
|
|
|
'url': 'https://www.pornhubpremium.com/pornstar/lily-labeau',
|
|
|
|
'only_matching': True,
|
2021-06-23 03:26:37 +02:00
|
|
|
}, {
|
2022-01-09 15:38:34 +01:00
|
|
|
'url': 'https://pornhubvybmsymdol4iibwgwtkpwmeyd6luq2gxajgjzfjvotyt5zhyd.onion/model/zoe_ph',
|
2021-06-23 03:26:37 +02:00
|
|
|
'only_matching': True,
|
2019-06-22 00:34:46 +02:00
|
|
|
}]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2021-08-19 03:41:24 +02:00
|
|
|
mobj = self._match_valid_url(url)
|
2019-06-22 00:34:46 +02:00
|
|
|
user_id = mobj.group('id')
|
2024-06-12 01:09:58 +02:00
|
|
|
videos_url = '{}/videos'.format(mobj.group('url'))
|
2023-04-25 22:46:14 +02:00
|
|
|
self._set_age_cookies(mobj.group('host'))
|
2021-02-04 08:56:01 +01:00
|
|
|
page = self._extract_page(url)
|
|
|
|
if page:
|
|
|
|
videos_url = update_url_query(videos_url, {'page': page})
|
2019-06-22 00:34:46 +02:00
|
|
|
return self.url_result(
|
2021-02-04 08:56:01 +01:00
|
|
|
videos_url, ie=PornHubPagedVideoListIE.ie_key(), video_id=user_id)
|
2019-06-22 00:34:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
class PornHubPagedPlaylistBaseIE(PornHubPlaylistBaseIE):
|
2019-10-05 16:43:31 +02:00
|
|
|
@staticmethod
|
|
|
|
def _has_more(webpage):
|
|
|
|
return re.search(
|
|
|
|
r'''(?x)
|
|
|
|
<li[^>]+\bclass=["\']page_next|
|
|
|
|
<link[^>]+\brel=["\']next|
|
|
|
|
<button[^>]+\bid=["\']moreDataBtn
|
|
|
|
''', webpage) is not None
|
|
|
|
|
2021-02-04 08:56:01 +01:00
|
|
|
def _entries(self, url, host, item_id):
|
|
|
|
page = self._extract_page(url)
|
2019-06-22 00:34:46 +02:00
|
|
|
|
2021-02-04 08:56:01 +01:00
|
|
|
VIDEOS = '/videos'
|
|
|
|
|
|
|
|
def download_page(base_url, num, fallback=False):
|
2024-06-12 01:09:58 +02:00
|
|
|
note = 'Downloading page {}{}'.format(num, ' (switch to fallback)' if fallback else '')
|
2021-02-04 08:56:01 +01:00
|
|
|
return self._download_webpage(
|
|
|
|
base_url, item_id, note, query={'page': num})
|
2019-06-22 01:01:43 +02:00
|
|
|
|
2021-02-04 08:56:01 +01:00
|
|
|
def is_404(e):
|
2023-07-09 09:53:02 +02:00
|
|
|
return isinstance(e.cause, HTTPError) and e.cause.status == 404
|
2021-02-04 08:56:01 +01:00
|
|
|
|
|
|
|
base_url = url
|
|
|
|
has_page = page is not None
|
|
|
|
first_page = page if has_page else 1
|
|
|
|
for page_num in (first_page, ) if has_page else itertools.count(first_page):
|
2019-06-22 00:34:46 +02:00
|
|
|
try:
|
2021-02-04 08:56:01 +01:00
|
|
|
try:
|
|
|
|
webpage = download_page(base_url, page_num)
|
|
|
|
except ExtractorError as e:
|
|
|
|
# Some sources may not be available via /videos page,
|
|
|
|
# trying to fallback to main page pagination (see [1])
|
|
|
|
# 1. https://github.com/ytdl-org/youtube-dl/issues/27853
|
|
|
|
if is_404(e) and page_num == first_page and VIDEOS in base_url:
|
|
|
|
base_url = base_url.replace(VIDEOS, '')
|
|
|
|
webpage = download_page(base_url, page_num, fallback=True)
|
|
|
|
else:
|
|
|
|
raise
|
2019-06-22 00:34:46 +02:00
|
|
|
except ExtractorError as e:
|
2021-02-04 08:56:01 +01:00
|
|
|
if is_404(e) and page_num != first_page:
|
2019-06-22 00:34:46 +02:00
|
|
|
break
|
|
|
|
raise
|
|
|
|
page_entries = self._extract_entries(webpage, host)
|
|
|
|
if not page_entries:
|
|
|
|
break
|
2021-02-04 08:56:01 +01:00
|
|
|
for e in page_entries:
|
|
|
|
yield e
|
2019-06-22 00:34:46 +02:00
|
|
|
if not self._has_more(webpage):
|
|
|
|
break
|
|
|
|
|
2021-02-04 08:56:01 +01:00
|
|
|
def _real_extract(self, url):
|
2021-08-19 03:41:24 +02:00
|
|
|
mobj = self._match_valid_url(url)
|
2021-02-04 08:56:01 +01:00
|
|
|
host = mobj.group('host')
|
|
|
|
item_id = mobj.group('id')
|
|
|
|
|
|
|
|
self._login(host)
|
2023-04-25 22:46:14 +02:00
|
|
|
self._set_age_cookies(host)
|
2021-02-04 08:56:01 +01:00
|
|
|
|
|
|
|
return self.playlist_result(self._entries(url, host, item_id), item_id)
|
2019-06-22 00:34:46 +02:00
|
|
|
|
|
|
|
|
2019-06-22 03:37:07 +02:00
|
|
|
class PornHubPagedVideoListIE(PornHubPagedPlaylistBaseIE):
|
2024-06-12 01:09:58 +02:00
|
|
|
_VALID_URL = rf'https?://(?:[^/]+\.)?{PornHubBaseIE._PORNHUB_HOST_RE}/(?!playlist/)(?P<id>(?:[^/]+/)*[^/?#&]+)'
|
2019-06-22 00:34:46 +02:00
|
|
|
_TESTS = [{
|
2019-06-22 01:01:43 +02:00
|
|
|
'url': 'https://www.pornhub.com/model/zoe_ph/videos',
|
2019-06-22 00:34:46 +02:00
|
|
|
'only_matching': True,
|
2016-03-27 20:50:46 +02:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.pornhub.com/users/rushandlia/videos',
|
|
|
|
'only_matching': True,
|
2019-06-22 00:34:46 +02:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos',
|
|
|
|
'info_dict': {
|
2019-06-22 03:37:07 +02:00
|
|
|
'id': 'pornstar/jenny-blighe/videos',
|
2019-06-22 00:34:46 +02:00
|
|
|
},
|
|
|
|
'playlist_mincount': 149,
|
2019-06-22 01:01:43 +02:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos?page=3',
|
|
|
|
'info_dict': {
|
2019-06-22 03:37:07 +02:00
|
|
|
'id': 'pornstar/jenny-blighe/videos',
|
2019-06-22 01:01:43 +02:00
|
|
|
},
|
|
|
|
'playlist_mincount': 40,
|
2018-02-16 19:17:06 +01:00
|
|
|
}, {
|
|
|
|
# default sorting as Top Rated Videos
|
|
|
|
'url': 'https://www.pornhub.com/channels/povd/videos',
|
|
|
|
'info_dict': {
|
2019-06-22 03:37:07 +02:00
|
|
|
'id': 'channels/povd/videos',
|
2018-02-16 19:17:06 +01:00
|
|
|
},
|
|
|
|
'playlist_mincount': 293,
|
|
|
|
}, {
|
|
|
|
# Top Rated Videos
|
|
|
|
'url': 'https://www.pornhub.com/channels/povd/videos?o=ra',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
# Most Recent Videos
|
|
|
|
'url': 'https://www.pornhub.com/channels/povd/videos?o=da',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
# Most Viewed Videos
|
|
|
|
'url': 'https://www.pornhub.com/channels/povd/videos?o=vi',
|
|
|
|
'only_matching': True,
|
2018-04-11 23:53:45 +02:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.pornhub.com/users/zoe_ph/videos/public',
|
|
|
|
'only_matching': True,
|
2019-06-22 00:34:46 +02:00
|
|
|
}, {
|
|
|
|
# Most Viewed Videos
|
|
|
|
'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=mv',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
# Top Rated Videos
|
|
|
|
'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=tr',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
# Longest Videos
|
|
|
|
'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=lg',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
# Newest Videos
|
|
|
|
'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=cm',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos/paid',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos/fanonly',
|
|
|
|
'only_matching': True,
|
2019-06-22 03:37:07 +02:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/video',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/video?page=3',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/video/search?search=123',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/categories/teen',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/categories/teen?page=3',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/hd',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/hd?page=3',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/described-video',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/described-video?page=2',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/video/incategories/60fps-1/hd-porn',
|
|
|
|
'only_matching': True,
|
2021-06-23 03:26:37 +02:00
|
|
|
}, {
|
2022-01-09 15:38:34 +01:00
|
|
|
'url': 'https://pornhubvybmsymdol4iibwgwtkpwmeyd6luq2gxajgjzfjvotyt5zhyd.onion/model/zoe_ph/videos',
|
2021-06-23 03:26:37 +02:00
|
|
|
'only_matching': True,
|
2016-02-18 17:29:17 +01:00
|
|
|
}]
|
|
|
|
|
2019-06-22 00:34:46 +02:00
|
|
|
@classmethod
|
|
|
|
def suitable(cls, url):
|
|
|
|
return (False
|
2019-06-22 03:37:07 +02:00
|
|
|
if PornHubIE.suitable(url) or PornHubUserIE.suitable(url) or PornHubUserVideosUploadIE.suitable(url)
|
2024-06-12 01:09:58 +02:00
|
|
|
else super().suitable(url))
|
2019-06-22 00:34:46 +02:00
|
|
|
|
2016-03-27 20:50:46 +02:00
|
|
|
|
2019-06-22 00:34:46 +02:00
|
|
|
class PornHubUserVideosUploadIE(PornHubPagedPlaylistBaseIE):
|
2024-06-12 01:09:58 +02:00
|
|
|
_VALID_URL = rf'(?P<url>https?://(?:[^/]+\.)?{PornHubBaseIE._PORNHUB_HOST_RE}/(?:(?:user|channel)s|model|pornstar)/(?P<id>[^/]+)/videos/upload)'
|
2019-06-22 00:34:46 +02:00
|
|
|
_TESTS = [{
|
|
|
|
'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos/upload',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'jenny-blighe',
|
|
|
|
},
|
|
|
|
'playlist_mincount': 129,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/model/zoe_ph/videos/upload',
|
|
|
|
'only_matching': True,
|
2021-06-23 03:26:37 +02:00
|
|
|
}, {
|
2022-01-09 15:38:34 +01:00
|
|
|
'url': 'http://pornhubvybmsymdol4iibwgwtkpwmeyd6luq2gxajgjzfjvotyt5zhyd.onion/pornstar/jenny-blighe/videos/upload',
|
2021-06-23 03:26:37 +02:00
|
|
|
'only_matching': True,
|
2019-06-22 00:34:46 +02:00
|
|
|
}]
|
2021-08-15 19:32:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
class PornHubPlaylistIE(PornHubPlaylistBaseIE):
|
2024-06-12 01:09:58 +02:00
|
|
|
_VALID_URL = rf'(?P<url>https?://(?:[^/]+\.)?{PornHubBaseIE._PORNHUB_HOST_RE}/playlist/(?P<id>[^/?#&]+))'
|
2021-08-15 19:32:48 +02:00
|
|
|
_TESTS = [{
|
|
|
|
'url': 'https://www.pornhub.com/playlist/44121572',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '44121572',
|
|
|
|
},
|
|
|
|
'playlist_count': 77,
|
|
|
|
}, {
|
|
|
|
'url': 'https://www.pornhub.com/playlist/4667351',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://de.pornhub.com/playlist/4667351',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'https://de.pornhub.com/playlist/4667351?page=2',
|
|
|
|
'only_matching': True,
|
|
|
|
}]
|
|
|
|
|
|
|
|
def _entries(self, url, host, item_id):
|
|
|
|
webpage = self._download_webpage(url, item_id, 'Downloading page 1')
|
|
|
|
playlist_id = self._search_regex(r'var\s+playlistId\s*=\s*"([^"]+)"', webpage, 'playlist_id')
|
|
|
|
video_count = int_or_none(
|
|
|
|
self._search_regex(r'var\s+itemsCount\s*=\s*([0-9]+)\s*\|\|', webpage, 'video_count'))
|
|
|
|
token = self._search_regex(r'var\s+token\s*=\s*"([^"]+)"', webpage, 'token')
|
|
|
|
page_count = math.ceil((video_count - 36) / 40.) + 1
|
|
|
|
page_entries = self._extract_entries(webpage, host)
|
|
|
|
|
|
|
|
def download_page(page_num):
|
2024-06-12 01:09:58 +02:00
|
|
|
note = f'Downloading page {page_num}'
|
|
|
|
page_url = f'https://www.{host}/playlist/viewChunked'
|
2021-08-15 19:32:48 +02:00
|
|
|
return self._download_webpage(page_url, item_id, note, query={
|
|
|
|
'id': playlist_id,
|
|
|
|
'page': page_num,
|
|
|
|
'token': token,
|
|
|
|
})
|
|
|
|
|
|
|
|
for page_num in range(1, page_count + 1):
|
|
|
|
if page_num > 1:
|
|
|
|
webpage = download_page(page_num)
|
|
|
|
page_entries = self._extract_entries(webpage, host)
|
|
|
|
if not page_entries:
|
|
|
|
break
|
2024-06-12 01:09:58 +02:00
|
|
|
yield from page_entries
|
2021-08-15 19:32:48 +02:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2021-08-19 03:41:24 +02:00
|
|
|
mobj = self._match_valid_url(url)
|
2021-08-15 19:32:48 +02:00
|
|
|
host = mobj.group('host')
|
|
|
|
item_id = mobj.group('id')
|
|
|
|
|
|
|
|
self._login(host)
|
2023-04-25 22:46:14 +02:00
|
|
|
self._set_age_cookies(host)
|
2021-08-15 19:32:48 +02:00
|
|
|
|
|
|
|
return self.playlist_result(self._entries(mobj.group('url'), host, item_id), item_id)
|