7 from .common
import InfoExtractor
8 from .openload
import PhantomJSwrapper
9 from ..compat
import compat_str
10 from ..networking
import Request
11 from ..networking
.exceptions
import HTTPError
30 class PornHubBaseIE(InfoExtractor
):
31 _NETRC_MACHINE
= 'pornhub'
32 _PORNHUB_HOST_RE
= r
'(?:(?P<host>pornhub(?:premium)?\.(?:com|net|org))|pornhubvybmsymdol4iibwgwtkpwmeyd6luq2gxajgjzfjvotyt5zhyd\.onion)'
34 def _download_webpage_handle(self
, *args
, **kwargs
):
35 def dl(*args
, **kwargs
):
36 return super(PornHubBaseIE
, self
)._download
_webpage
_handle
(*args
, **kwargs
)
38 ret
= dl(*args
, **kwargs
)
45 if any(re
.search(p
, webpage
) for p
in (
46 r
'<body\b[^>]+\bonload=["\']go\
(\
)',
47 r'document\
.cookie\s
*=\s
*["\']RNKEY=',
48 r'document\.location\.reload\(true\)')):
49 url_or_request = args[0]
50 url = (url_or_request.url
51 if isinstance(url_or_request, Request)
53 phantom = PhantomJSwrapper(self, required_version='2.0')
54 phantom.get(url, html=webpage)
55 webpage, urlh = dl(*args, **kwargs)
59 def _real_initialize(self):
60 self._logged_in = False
62 def _set_age_cookies(self, host):
63 self._set_cookie(host, 'age_verified', '1')
64 self._set_cookie(host, 'accessAgeDisclaimerPH', '1')
65 self._set_cookie(host, 'accessAgeDisclaimerUK', '1')
66 self._set_cookie(host, 'accessPH', '1')
68 def _login(self, host):
72 site = host.split('.')[0]
74 # Both sites pornhub and pornhubpremium have separate accounts
75 # so there should be an option to provide credentials for both.
76 # At the same time some videos are available under the same video id
77 # on both sites so that we have to identify them as the same video.
78 # For that purpose we have to keep both in the same extractor
79 # but under different netrc machines.
80 username, password = self._get_login_info(netrc_machine=site)
84 login_url = 'https://www.%s/%slogin' % (host, 'premium/' if 'premium' in host else '')
85 login_page = self._download_webpage(
86 login_url, None, 'Downloading %s login page' % site)
88 def is_logged(webpage):
89 return any(re.search(p, webpage) for p in (
90 r'id="profileMenuDropdown
"',
91 r'class="ph
-icon
-logout
"'))
93 if is_logged(login_page):
94 self._logged_in = True
97 login_form = self._hidden_inputs(login_page)
101 'password': password,
104 response = self._download_json(
105 'https://www.%s/front/authenticate' % host, None,
106 'Logging in to %s' % site,
107 data=urlencode_postdata(login_form),
109 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
110 'Referer': login_url,
111 'X-Requested-With': 'XMLHttpRequest',
114 if response.get('success') == '1':
115 self._logged_in = True
118 message = response.get('message')
119 if message is not None:
120 raise ExtractorError(
121 'Unable to login: %s' % message, expected=True)
123 raise ExtractorError('Unable to log in')
126 class PornHubIE(PornHubBaseIE):
127 IE_DESC = 'PornHub and Thumbzilla'
128 _VALID_URL = r'''(?x)
133 /(?:(?:view_video\.php|video/show)\?viewkey=|embed/)|
134 (?:www\.)?thumbzilla\.com/video/
137 ''' % PornHubBaseIE._PORNHUB_HOST_RE
138 _EMBED_REGEX = [r'<iframe[^>]+?src=["\'](?P
<url
>(?
:https?
:)?
//(?
:www\
.)?
pornhub(?
:premium
)?\
.(?
:com|net|org
)/embed
/[\da
-z
]+)']
140 'url
': 'http
://www
.pornhub
.com
/view_video
.php?viewkey
=648719015',
141 'md5
': 'a6391306d050e4547f62b3f485dd9ba9
',
145 'title
': 'Seductive Indian beauty strips down
and fingers her pink pussy
',
147 'upload_date
': '20130628',
148 'timestamp
': 1372447216,
152 'dislike_count
': int,
153 'comment_count
': int,
161 'url
': 'http
://www
.pornhub
.com
/view_video
.php?viewkey
=1331683002',
166 'upload_date
': '20150213',
167 'timestamp
': 1423804862,
171 'dislike_count
': int,
172 'comment_count
': int,
178 'skip_download
': True,
180 'skip
': 'Video has been flagged
for verification
in accordance
with our trust
and safety policy
',
183 'url
': 'https
://www
.pornhub
.com
/view_video
.php?viewkey
=ph5af5fef7c2aa7
',
185 'id': 'ph5af5fef7c2aa7
',
187 'title
': 'BFFS
- Cute Teen Girls Share Cock On the Floor
',
192 'dislike_count
': int,
193 'comment_count
': int,
204 'skip_download
': True,
206 'skip
': 'This video has been disabled
',
208 'url
': 'http
://www
.pornhub
.com
/view_video
.php?viewkey
=ph601dc30bae19a
',
210 'id': 'ph601dc30bae19a
',
211 'uploader
': 'Projekt Melody
',
212 'uploader_id
': 'projekt
-melody
',
213 'upload_date
': '20210205',
214 'title
': '"Welcome to My Pussy Mansion" - CB
Stream (02/03/21)',
215 'thumbnail
': r're
:https?
://.+',
218 'url
': 'http
://www
.pornhub
.com
/view_video
.php?viewkey
=ph557bbb6676d2d
',
219 'only_matching
': True,
221 # removed at the request of cam4.com
222 'url
': 'http
://fr
.pornhub
.com
/view_video
.php?viewkey
=ph55ca2f9760862
',
223 'only_matching
': True,
225 # removed at the request of the copyright owner
226 'url
': 'http
://www
.pornhub
.com
/view_video
.php?viewkey
=788152859',
227 'only_matching
': True,
229 # removed by uploader
230 'url
': 'http
://www
.pornhub
.com
/view_video
.php?viewkey
=ph572716d15a111
',
231 'only_matching
': True,
234 'url
': 'http
://www
.pornhub
.com
/view_video
.php?viewkey
=ph56fd731fce6b7
',
235 'only_matching
': True,
237 'url
': 'https
://www
.thumbzilla
.com
/video
/ph56c6114abd99a
/horny
-girlfriend
-sex
',
238 'only_matching
': True,
240 'url
': 'http
://www
.pornhub
.com
/video
/show?viewkey
=648719015',
241 'only_matching
': True,
243 'url
': 'https
://www
.pornhub
.net
/view_video
.php?viewkey
=203640933',
244 'only_matching
': True,
246 'url
': 'https
://www
.pornhub
.org
/view_video
.php?viewkey
=203640933',
247 'only_matching
': True,
249 'url
': 'https
://www
.pornhubpremium
.com
/view_video
.php?viewkey
=ph5e4acdae54a82
',
250 'only_matching
': True,
252 # Some videos are available with the same id on both premium
253 # and non-premium sites (e.g. this and the following test)
254 'url
': 'https
://www
.pornhub
.com
/view_video
.php?viewkey
=ph5f75b0f4b18e3
',
255 'only_matching
': True,
257 'url
': 'https
://www
.pornhubpremium
.com
/view_video
.php?viewkey
=ph5f75b0f4b18e3
',
258 'only_matching
': True,
261 'url
': 'https
://www
.pornhub
.com
/view_video
.php?viewkey
=ph5a9813bfa7156
',
262 'only_matching
': True,
264 'url
': 'http
://pornhubvybmsymdol4iibwgwtkpwmeyd6luq2gxajgjzfjvotyt5zhyd
.onion
/view_video
.php?viewkey
=ph5a9813bfa7156
',
265 'only_matching
': True,
268 def _extract_count(self, pattern, webpage, name):
269 return str_to_int(self._search_regex(pattern, webpage, '%s count
' % name, default=None))
271 def _real_extract(self, url):
272 mobj = self._match_valid_url(url)
273 host = mobj.group('host
') or 'pornhub
.com
'
274 video_id = mobj.group('id')
277 self._set_age_cookies(host)
279 def dl_webpage(platform):
280 self._set_cookie(host, 'platform
', platform)
281 return self._download_webpage(
282 'https
://www
.%s/view_video
.php?viewkey
=%s' % (host, video_id),
283 video_id, 'Downloading
%s webpage
' % platform)
285 webpage = dl_webpage('pc
')
287 error_msg = self._html_search_regex(
288 (r'(?s
)<div
[^
>]+class=(["\'])(?:(?!\1).)*\b(?:removed|userMessageSection)\b(?:(?!\1).)*\1[^>]*>(?P<error>.+?)</div>',
289 r'(?s)<section[^>]+class=["\']noVideo
["\'][^>]*>(?P<error>.+?)</section>'),
290 webpage, 'error message', default=None, group='error')
292 error_msg = re.sub(r'\s+', ' ', error_msg)
293 raise ExtractorError(
294 'PornHub said: %s' % error_msg,
295 expected=True, video_id=video_id)
297 if any(re.search(p, webpage) for p in (
298 r'class=["\']geoBlocked
["\']',
299 r'>\s*This content is unavailable in your country')):
300 self.raise_geo_restricted()
302 # video_title from flashvars contains whitespace instead of non-ASCII (see
303 # http://www.pornhub.com/view_video.php?viewkey=1331683002), not relying
305 title = self._html_search_meta(
306 'twitter:title', webpage, default=None) or self._html_search_regex(
307 (r'(?s)<h1[^>]+class=["\']title
["\'][^>]*>(?P<title>.+?)</h1>',
308 r'<div[^>]+data-video-title=(["\'])(?P
<title
>(?
:(?
!\
1).)+)\
1',
309 r'shareTitle
["\']\s*[=:]\s*(["\'])(?P
<title
>(?
:(?
!\
1).)+)\
1'),
310 webpage, 'title
', group='title
')
313 video_urls_set = set()
316 flashvars = self._parse_json(
318 r'var\s
+flashvars_\d
+\s
*=\s
*({.+?}
);', webpage, 'flashvars
', default='{}'),
321 subtitle_url = url_or_none(flashvars.get('closedCaptionsFile
'))
323 subtitles.setdefault('en
', []).append({
327 thumbnail = flashvars.get('image_url
')
328 duration = int_or_none(flashvars.get('video_duration
'))
329 media_definitions = flashvars.get('mediaDefinitions
')
330 if isinstance(media_definitions, list):
331 for definition in media_definitions:
332 if not isinstance(definition, dict):
334 video_url = definition.get('videoUrl
')
335 if not video_url or not isinstance(video_url, compat_str):
337 if video_url in video_urls_set:
339 video_urls_set.add(video_url)
341 (video_url, int_or_none(definition.get('quality
'))))
343 thumbnail, duration = [None] * 2
345 def extract_js_vars(webpage, pattern, default=NO_DEFAULT):
346 assignments = self._search_regex(
347 pattern, webpage, 'encoded url
', default=default)
351 assignments = assignments.split(';')
355 def parse_js_value(inp):
356 inp = re.sub(r'/\
*(?
:(?
!\
*/).)*?\
*/', '', inp)
358 inps = inp.split('+')
359 return functools.reduce(
360 operator.concat, map(parse_js_value, inps))
364 return remove_quotes(inp)
366 for assn in assignments:
370 assn = re.sub(r'var\s
+', '', assn)
371 vname, value = assn.split('=', 1)
372 js_vars[vname] = parse_js_value(value)
375 def add_video_url(video_url):
376 v_url = url_or_none(video_url)
379 if v_url in video_urls_set:
381 video_urls.append((v_url, None))
382 video_urls_set.add(v_url)
384 def parse_quality_items(quality_items):
385 q_items = self._parse_json(quality_items, video_id, fatal=False)
386 if not isinstance(q_items, list):
389 if isinstance(item, dict):
390 add_video_url(item.get('url
'))
393 FORMAT_PREFIXES = ('media
', 'quality
', 'qualityItems
')
394 js_vars = extract_js_vars(
395 webpage, r'(var\s
+(?
:%s)_
.+)' % '|
'.join(FORMAT_PREFIXES),
398 for key, format_url in js_vars.items():
399 if key.startswith(FORMAT_PREFIXES[-1]):
400 parse_quality_items(format_url)
401 elif any(key.startswith(p) for p in FORMAT_PREFIXES[:2]):
402 add_video_url(format_url)
403 if not video_urls and re.search(
404 r'<[^
>]+\bid
=["\']lockedPlayer', webpage):
405 raise ExtractorError(
406 'Video %s is locked' % video_id, expected=True)
409 js_vars = extract_js_vars(
410 dl_webpage('tv'), r'(var.+?mediastring.+?)</script>')
411 add_video_url(js_vars['mediastring'])
413 for mobj in re.finditer(
414 r'<a[^>]+\bclass=["\']downloadBtn
\b[^
>]+\bhref
=(["\'])(?P<url>(?:(?!\1).)+)\1',
416 video_url = mobj.group('url')
417 if video_url not in video_urls_set:
418 video_urls.append((video_url, None))
419 video_urls_set.add(video_url)
424 def add_format(format_url, height=None):
425 ext = determine_ext(format_url)
427 formats.extend(self._extract_mpd_formats(
428 format_url, video_id, mpd_id='dash', fatal=False))
431 formats.extend(self._extract_m3u8_formats(
432 format_url, video_id, 'mp4', entry_protocol='m3u8_native',
433 m3u8_id='hls', fatal=False))
436 height = int_or_none(self._search_regex(
437 r'(?P<height>\d+)[pP]?_\d+[kK]', format_url, 'height',
441 'format_id': format_field(height, None, '%dp'),
445 for video_url, height in video_urls:
447 upload_date = self._search_regex(
448 r'/(\d{6}/\d{2})/', video_url, 'upload data', default=None)
450 upload_date = upload_date.replace('/', '')
451 if '/video/get_media' in video_url:
452 medias = self._download_json(video_url, video_id, fatal=False)
453 if isinstance(medias, list):
455 if not isinstance(media, dict):
457 video_url = url_or_none(media.get('videoUrl'))
460 height = int_or_none(media.get('quality'))
461 add_format(video_url, height)
463 add_format(video_url)
465 model_profile = self._search_json(
466 r'var\s+MODEL_PROFILE\s*=', webpage, 'model profile', video_id, fatal=False)
467 video_uploader = self._html_search_regex(
468 r'(?s)From: .+?<(?:a\b[^>]+\bhref=["\']/(?
:(?
:user|channel
)s|model|pornstar
)/|span
\b[^
>]+\bclass
=["\']username)[^>]+>(.+?)<',
469 webpage, 'uploader', default=None) or model_profile.get('username')
471 def extract_vote_count(kind, name):
472 return self._extract_count(
473 (r'<span[^>]+\bclass="votes
%s"[^>]*>([\d,\.]+)</span>' % kind,
474 r'<span[^>]+\bclass=["\']votes
%s["\'][^>]*\bdata-rating=["\'](\d
+)' % kind),
477 view_count = self._extract_count(
478 r'<span
class="count">([\d
,\
.]+)</span
> [Vv
]iews
', webpage, 'view
')
479 like_count = extract_vote_count('Up
', 'like
')
480 dislike_count = extract_vote_count('Down
', 'dislike
')
481 comment_count = self._extract_count(
482 r'All Comments\s
*<span
>\
(([\d
,.]+)\
)', webpage, 'comment
')
484 def extract_list(meta_key):
485 div = self._search_regex(
486 r'(?s
)<div
[^
>]+\bclass
=["\'].*?\b%sWrapper[^>]*>(.+?)</div>'
487 % meta_key, webpage, meta_key, default=None)
489 return [clean_html(x).strip() for x in re.findall(r'(?s)<a[^>]+\bhref=[^>]+>.+?</a>', div)]
491 info = self._search_json_ld(webpage, video_id, default={})
492 # description provided in JSON-LD is irrelevant
493 info['description'] = None
497 'uploader': video_uploader,
498 'uploader_id': remove_start(model_profile.get('modelProfileLink'), '/model/'),
499 'upload_date': upload_date,
501 'thumbnail': thumbnail,
502 'duration': duration,
503 'view_count': view_count,
504 'like_count': like_count,
505 'dislike_count': dislike_count,
506 'comment_count': comment_count,
509 'tags': extract_list('tags'),
510 'categories': extract_list('categories'),
511 'cast': extract_list('pornstars'),
512 'subtitles': subtitles,
516 class PornHubPlaylistBaseIE(PornHubBaseIE):
517 def _extract_page(self, url):
518 return int_or_none(self._search_regex(
519 r'\bpage=(\d+)', url, 'page', default=None))
521 def _extract_entries(self, webpage, host):
522 # Only process container div with main playlist content skipping
523 # drop-down menu that uses similar pattern for videos (see
524 # https://github.com/ytdl-org/youtube-dl/issues/11594).
525 container = self._search_regex(
526 r'(?s)(<div[^>]+class=["\']container
.+)', webpage,
527 'container
', default=webpage)
531 'http
://www
.%s/%s' % (host, video_url),
532 PornHubIE.ie_key(), video_title=title)
533 for video_url, title in orderedSet(re.findall(
534 r'href
="/?(view_video\.php\?.*\bviewkey=[\da-z]+[^"]*)"[^>]*\s+title="([^
"]+)"',
539 class PornHubUserIE(PornHubPlaylistBaseIE):
540 _VALID_URL = r'(?P
<url
>https?
://(?
:[^
/]+\
.)?
%s/(?
:(?
:user|channel
)s|model|pornstar
)/(?P
<id>[^
/?
#&]+))(?:[?#&]|/(?!videos)|$)' % PornHubBaseIE._PORNHUB_HOST_RE
542 'url': 'https://www.pornhub.com/model/zoe_ph',
543 'playlist_mincount': 118,
545 'url': 'https://www.pornhub.com/pornstar/liz-vicious',
549 'playlist_mincount': 118,
551 'url': 'https://www.pornhub.com/users/russianveet69',
552 'only_matching': True,
554 'url': 'https://www.pornhub.com/channels/povd',
555 'only_matching': True,
557 'url': 'https://www.pornhub.com/model/zoe_ph?abc=1',
558 'only_matching': True,
560 # Unavailable via /videos page, but available with direct pagination
561 # on pornstar page (see [1]), requires premium
562 # 1. https://github.com/ytdl-org/youtube-dl/issues/27853
563 'url': 'https://www.pornhubpremium.com/pornstar/sienna-west',
564 'only_matching': True,
566 # Same as before, multi page
567 'url': 'https://www.pornhubpremium.com/pornstar/lily-labeau',
568 'only_matching': True,
570 'url': 'https://pornhubvybmsymdol4iibwgwtkpwmeyd6luq2gxajgjzfjvotyt5zhyd.onion/model/zoe_ph',
571 'only_matching': True,
574 def _real_extract(self
, url
):
575 mobj
= self
._match
_valid
_url
(url
)
576 user_id
= mobj
.group('id')
577 videos_url
= '%s/videos' % mobj
.group('url')
578 self
._set
_age
_cookies
(mobj
.group('host'))
579 page
= self
._extract
_page
(url
)
581 videos_url
= update_url_query(videos_url
, {'page': page}
)
582 return self
.url_result(
583 videos_url
, ie
=PornHubPagedVideoListIE
.ie_key(), video_id
=user_id
)
586 class PornHubPagedPlaylistBaseIE(PornHubPlaylistBaseIE
):
588 def _has_more(webpage
):
591 <li[^>]+\bclass=["\']page_next|
592 <link
[^
>]+\brel
=["\']next|
593 <button[^>]+\bid=["\']moreDataBtn
594 ''', webpage) is not None
596 def _entries(self, url, host, item_id):
597 page = self._extract_page(url)
601 def download_page(base_url, num, fallback=False):
602 note = 'Downloading page %d%s' % (num, ' (switch to fallback)' if fallback else '')
603 return self._download_webpage(
604 base_url, item_id, note, query={'page': num})
607 return isinstance(e.cause, HTTPError) and e.cause.status == 404
610 has_page = page is not None
611 first_page = page if has_page else 1
612 for page_num in (first_page, ) if has_page else itertools.count(first_page):
615 webpage = download_page(base_url, page_num)
616 except ExtractorError as e:
617 # Some sources may not be available via /videos page,
618 # trying to fallback to main page pagination (see [1])
619 # 1. https://github.com/ytdl-org/youtube-dl/issues/27853
620 if is_404(e) and page_num == first_page and VIDEOS in base_url:
621 base_url = base_url.replace(VIDEOS, '')
622 webpage = download_page(base_url, page_num, fallback=True)
625 except ExtractorError as e:
626 if is_404(e) and page_num != first_page:
629 page_entries = self._extract_entries(webpage, host)
632 for e in page_entries:
634 if not self._has_more(webpage):
637 def _real_extract(self, url):
638 mobj = self._match_valid_url(url)
639 host = mobj.group('host')
640 item_id = mobj.group('id')
643 self._set_age_cookies(host)
645 return self.playlist_result(self._entries(url, host, item_id), item_id)
648 class PornHubPagedVideoListIE(PornHubPagedPlaylistBaseIE):
649 _VALID_URL = r'https?://(?:[^/]+\.)?%s/(?!playlist/)(?P<id>(?:[^/]+/)*[^/?#&]+)' % PornHubBaseIE._PORNHUB_HOST_RE
651 'url': 'https://www.pornhub.com/model/zoe_ph/videos',
652 'only_matching': True,
654 'url': 'http://www.pornhub.com/users/rushandlia/videos',
655 'only_matching': True,
657 'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos',
659 'id': 'pornstar/jenny-blighe/videos',
661 'playlist_mincount': 149,
663 'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos?page=3',
665 'id': 'pornstar/jenny-blighe/videos',
667 'playlist_mincount': 40,
669 # default sorting as Top Rated Videos
670 'url': 'https://www.pornhub.com/channels/povd/videos',
672 'id': 'channels/povd/videos',
674 'playlist_mincount': 293,
677 'url': 'https://www.pornhub.com/channels/povd/videos?o=ra',
678 'only_matching': True,
681 'url': 'https://www.pornhub.com/channels/povd/videos?o=da',
682 'only_matching': True,
685 'url': 'https://www.pornhub.com/channels/povd/videos?o=vi',
686 'only_matching': True,
688 'url': 'http://www.pornhub.com/users/zoe_ph/videos/public',
689 'only_matching': True,
692 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=mv',
693 'only_matching': True,
696 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=tr',
697 'only_matching': True,
700 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=lg',
701 'only_matching': True,
704 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=cm',
705 'only_matching': True,
707 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos/paid',
708 'only_matching': True,
710 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos/fanonly',
711 'only_matching': True,
713 'url': 'https://www.pornhub.com/video',
714 'only_matching': True,
716 'url': 'https://www.pornhub.com/video?page=3',
717 'only_matching': True,
719 'url': 'https://www.pornhub.com/video/search?search=123',
720 'only_matching': True,
722 'url': 'https://www.pornhub.com/categories/teen',
723 'only_matching': True,
725 'url': 'https://www.pornhub.com/categories/teen?page=3',
726 'only_matching': True,
728 'url': 'https://www.pornhub.com/hd',
729 'only_matching': True,
731 'url': 'https://www.pornhub.com/hd?page=3',
732 'only_matching': True,
734 'url': 'https://www.pornhub.com/described-video',
735 'only_matching': True,
737 'url': 'https://www.pornhub.com/described-video?page=2',
738 'only_matching': True,
740 'url': 'https://www.pornhub.com/video/incategories/60fps-1/hd-porn',
741 'only_matching': True,
743 'url': 'https://pornhubvybmsymdol4iibwgwtkpwmeyd6luq2gxajgjzfjvotyt5zhyd.onion/model/zoe_ph/videos',
744 'only_matching': True,
748 def suitable(cls, url):
750 if PornHubIE.suitable(url) or PornHubUserIE.suitable(url) or PornHubUserVideosUploadIE.suitable(url)
751 else super(PornHubPagedVideoListIE, cls).suitable(url))
754 class PornHubUserVideosUploadIE(PornHubPagedPlaylistBaseIE):
755 _VALID_URL = r'(?P<url>https?://(?:[^/]+\.)?%s/(?:(?:user|channel)s|model|pornstar)/(?P<id>[^/]+)/videos/upload)' % PornHubBaseIE._PORNHUB_HOST_RE
757 'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos/upload',
759 'id': 'jenny-blighe',
761 'playlist_mincount': 129,
763 'url': 'https://www.pornhub.com/model/zoe_ph/videos/upload',
764 'only_matching': True,
766 'url': 'http://pornhubvybmsymdol4iibwgwtkpwmeyd6luq2gxajgjzfjvotyt5zhyd.onion/pornstar/jenny-blighe/videos/upload',
767 'only_matching': True,
771 class PornHubPlaylistIE(PornHubPlaylistBaseIE):
772 _VALID_URL = r'(?P<url>https?://(?:[^/]+\.)?%s/playlist/(?P<id>[^/?#&]+))' % PornHubBaseIE._PORNHUB_HOST_RE
774 'url': 'https://www.pornhub.com/playlist/44121572',
778 'playlist_count': 77,
780 'url': 'https://www.pornhub.com/playlist/4667351',
781 'only_matching': True,
783 'url': 'https://de.pornhub.com/playlist/4667351',
784 'only_matching': True,
786 'url': 'https://de.pornhub.com/playlist/4667351?page=2',
787 'only_matching': True,
790 def _entries(self, url, host, item_id):
791 webpage = self._download_webpage(url, item_id, 'Downloading page 1')
792 playlist_id = self._search_regex(r'var\s+playlistId\s*=\s*"([^"]+)"', webpage, 'playlist_id')
793 video_count = int_or_none(
794 self._search_regex(r'var\s+itemsCount\s*=\s*([0-9]+)\s*\|\|', webpage, 'video_count'))
795 token = self._search_regex(r'var\s+token\s*=\s*"([^"]+)"', webpage, 'token')
796 page_count = math.ceil((video_count - 36) / 40.) + 1
797 page_entries = self._extract_entries(webpage, host)
799 def download_page(page_num):
800 note = 'Downloading page {}'.format(page_num)
801 page_url = 'https://www.{}/playlist/viewChunked'.format(host)
802 return self._download_webpage(page_url, item_id, note, query={
808 for page_num in range(1, page_count + 1):
810 webpage = download_page(page_num)
811 page_entries = self._extract_entries(webpage, host)
814 for e in page_entries:
817 def _real_extract(self, url):
818 mobj = self._match_valid_url(url)
819 host = mobj.group('host')
820 item_id = mobj.group('id')
823 self._set_age_cookies(host)
825 return self.playlist_result(self._entries(mobj.group('url'), host, item_id), item_id)