7 from .common
import InfoExtractor
11 compat_urllib_request
,
13 from .openload
import PhantomJSwrapper
31 class PornHubBaseIE(InfoExtractor
):
32 _NETRC_MACHINE
= 'pornhub'
33 _PORNHUB_HOST_RE
= r
'(?:(?P<host>pornhub(?:premium)?\.(?:com|net|org))|pornhubvybmsymdol4iibwgwtkpwmeyd6luq2gxajgjzfjvotyt5zhyd\.onion)'
35 def _download_webpage_handle(self
, *args
, **kwargs
):
36 def dl(*args
, **kwargs
):
37 return super(PornHubBaseIE
, self
)._download
_webpage
_handle
(*args
, **kwargs
)
39 ret
= dl(*args
, **kwargs
)
46 if any(re
.search(p
, webpage
) for p
in (
47 r
'<body\b[^>]+\bonload=["\']go\
(\
)',
48 r'document\
.cookie\s
*=\s
*["\']RNKEY=',
49 r'document\.location\.reload\(true\)')):
50 url_or_request = args[0]
51 url = (url_or_request.get_full_url()
52 if isinstance(url_or_request, compat_urllib_request.Request)
54 phantom = PhantomJSwrapper(self, required_version='2.0')
55 phantom.get(url, html=webpage)
56 webpage, urlh = dl(*args, **kwargs)
60 def _real_initialize(self):
61 self._logged_in = False
63 def _login(self, host):
67 site = host.split('.')[0]
69 # Both sites pornhub and pornhubpremium have separate accounts
70 # so there should be an option to provide credentials for both.
71 # At the same time some videos are available under the same video id
72 # on both sites so that we have to identify them as the same video.
73 # For that purpose we have to keep both in the same extractor
74 # but under different netrc machines.
75 username, password = self._get_login_info(netrc_machine=site)
79 login_url = 'https://www.%s/%slogin' % (host, 'premium/' if 'premium' in host else '')
80 login_page = self._download_webpage(
81 login_url, None, 'Downloading %s login page' % site)
83 def is_logged(webpage):
84 return any(re.search(p, webpage) for p in (
85 r'class=["\']signOut
',
86 r'>Sign\s
+[Oo
]ut\s
*<'))
88 if is_logged(login_page):
89 self._logged_in = True
92 login_form = self._hidden_inputs(login_page)
99 response = self._download_json(
100 'https
://www
.%s/front
/authenticate
' % host, None,
101 'Logging
in to
%s' % site,
102 data=urlencode_postdata(login_form),
104 'Content
-Type
': 'application
/x
-www
-form
-urlencoded
; charset
=UTF
-8',
105 'Referer
': login_url,
106 'X
-Requested
-With
': 'XMLHttpRequest
',
109 if response.get('success
') == '1':
110 self._logged_in = True
113 message = response.get('message
')
114 if message is not None:
115 raise ExtractorError(
116 'Unable to login
: %s' % message, expected=True)
118 raise ExtractorError('Unable to log
in')
121 class PornHubIE(PornHubBaseIE):
122 IE_DESC = 'PornHub
and Thumbzilla
'
123 _VALID_URL = r'''(?x)
128 /(?:(?:view_video\.php|video/show)\?viewkey=|embed/)|
129 (?:www\.)?thumbzilla\.com/video/
132 ''' % PornHubBaseIE._PORNHUB_HOST_RE
134 'url
': 'http
://www
.pornhub
.com
/view_video
.php?viewkey
=648719015',
135 'md5
': 'a6391306d050e4547f62b3f485dd9ba9
',
139 'title
': 'Seductive Indian beauty strips down
and fingers her pink pussy
',
141 'upload_date
': '20130628',
142 'timestamp
': 1372447216,
146 'dislike_count
': int,
147 'comment_count
': int,
155 'url
': 'http
://www
.pornhub
.com
/view_video
.php?viewkey
=1331683002',
160 'upload_date
': '20150213',
161 'timestamp
': 1423804862,
165 'dislike_count
': int,
166 'comment_count
': int,
172 'skip_download
': True,
174 'skip
': 'Video has been flagged
for verification
in accordance
with our trust
and safety policy
',
177 'url
': 'https
://www
.pornhub
.com
/view_video
.php?viewkey
=ph5af5fef7c2aa7
',
179 'id': 'ph5af5fef7c2aa7
',
181 'title
': 'BFFS
- Cute Teen Girls Share Cock On the Floor
',
186 'dislike_count
': int,
187 'comment_count
': int,
198 'skip_download
': True,
200 'skip
': 'This video has been disabled
',
202 'url
': 'http
://www
.pornhub
.com
/view_video
.php?viewkey
=ph557bbb6676d2d
',
203 'only_matching
': True,
205 # removed at the request of cam4.com
206 'url
': 'http
://fr
.pornhub
.com
/view_video
.php?viewkey
=ph55ca2f9760862
',
207 'only_matching
': True,
209 # removed at the request of the copyright owner
210 'url
': 'http
://www
.pornhub
.com
/view_video
.php?viewkey
=788152859',
211 'only_matching
': True,
213 # removed by uploader
214 'url
': 'http
://www
.pornhub
.com
/view_video
.php?viewkey
=ph572716d15a111
',
215 'only_matching
': True,
218 'url
': 'http
://www
.pornhub
.com
/view_video
.php?viewkey
=ph56fd731fce6b7
',
219 'only_matching
': True,
221 'url
': 'https
://www
.thumbzilla
.com
/video
/ph56c6114abd99a
/horny
-girlfriend
-sex
',
222 'only_matching
': True,
224 'url
': 'http
://www
.pornhub
.com
/video
/show?viewkey
=648719015',
225 'only_matching
': True,
227 'url
': 'https
://www
.pornhub
.net
/view_video
.php?viewkey
=203640933',
228 'only_matching
': True,
230 'url
': 'https
://www
.pornhub
.org
/view_video
.php?viewkey
=203640933',
231 'only_matching
': True,
233 'url
': 'https
://www
.pornhubpremium
.com
/view_video
.php?viewkey
=ph5e4acdae54a82
',
234 'only_matching
': True,
236 # Some videos are available with the same id on both premium
237 # and non-premium sites (e.g. this and the following test)
238 'url
': 'https
://www
.pornhub
.com
/view_video
.php?viewkey
=ph5f75b0f4b18e3
',
239 'only_matching
': True,
241 'url
': 'https
://www
.pornhubpremium
.com
/view_video
.php?viewkey
=ph5f75b0f4b18e3
',
242 'only_matching
': True,
245 'url
': 'https
://www
.pornhub
.com
/view_video
.php?viewkey
=ph5a9813bfa7156
',
246 'only_matching
': True,
248 'url
': 'http
://pornhubvybmsymdol4iibwgwtkpwmeyd6luq2gxajgjzfjvotyt5zhyd
.onion
/view_video
.php?viewkey
=ph5a9813bfa7156
',
249 'only_matching
': True,
253 def _extract_urls(webpage):
255 r'<iframe
[^
>]+?src
=["\'](?P<url>(?:https?:)?//(?:www\.)?pornhub(?:premium)?\.(?:com|net|org)/embed/[\da-z]+)',
258 def _extract_count(self, pattern, webpage, name):
259 return str_to_int(self._search_regex(pattern, webpage, '%s count' % name, default=None))
261 def _real_extract(self, url):
262 mobj = self._match_valid_url(url)
263 host = mobj.group('host') or 'pornhub.com'
264 video_id = mobj.group('id')
268 self._set_cookie(host, 'age_verified', '1')
270 def dl_webpage(platform):
271 self._set_cookie(host, 'platform', platform)
272 return self._download_webpage(
273 'https://www.%s/view_video.php?viewkey=%s' % (host, video_id),
274 video_id, 'Downloading %s webpage' % platform)
276 webpage = dl_webpage('pc')
278 error_msg = self._html_search_regex(
279 (r'(?s)<div[^>]+class=(["\'])(?
:(?
!\
1).)*\b(?
:removed|userMessageSection
)\b(?
:(?
!\
1).)*\
1[^
>]*>(?P
<error
>.+?
)</div
>',
280 r'(?s
)<section
[^
>]+class=["\']noVideo["\'][^
>]*>(?P
<error
>.+?
)</section
>'),
281 webpage, 'error message
', default=None, group='error
')
283 error_msg = re.sub(r'\s
+', ' ', error_msg)
284 raise ExtractorError(
285 'PornHub said
: %s' % error_msg,
286 expected=True, video_id=video_id)
288 if any(re.search(p, webpage) for p in (
289 r'class=["\']geoBlocked["\']',
290 r'>\s
*This content
is unavailable
in your country
')):
291 self.raise_geo_restricted()
293 # video_title from flashvars contains whitespace instead of non-ASCII (see
294 # http://www.pornhub.com/view_video.php?viewkey=1331683002), not relying
296 title = self._html_search_meta(
297 'twitter
:title
', webpage, default=None) or self._html_search_regex(
298 (r'(?s
)<h1
[^
>]+class=["\']title["\'][^
>]*>(?P
<title
>.+?
)</h1
>',
299 r'<div
[^
>]+data
-video
-title
=(["\'])(?P<title>(?:(?!\1).)+)\1',
300 r'shareTitle["\']\s
*[=:]\s
*(["\'])(?P<title>(?:(?!\1).)+)\1'),
301 webpage, 'title', group='title')
304 video_urls_set = set()
307 flashvars = self._parse_json(
309 r'var\s+flashvars_\d+\s*=\s*({.+?});', webpage, 'flashvars', default='{}'),
312 subtitle_url = url_or_none(flashvars.get('closedCaptionsFile'))
314 subtitles.setdefault('en', []).append({
318 thumbnail = flashvars.get('image_url')
319 duration = int_or_none(flashvars.get('video_duration'))
320 media_definitions = flashvars.get('mediaDefinitions')
321 if isinstance(media_definitions, list):
322 for definition in media_definitions:
323 if not isinstance(definition, dict):
325 video_url = definition.get('videoUrl')
326 if not video_url or not isinstance(video_url, compat_str):
328 if video_url in video_urls_set:
330 video_urls_set.add(video_url)
332 (video_url, int_or_none(definition.get('quality'))))
334 thumbnail, duration = [None] * 2
336 def extract_js_vars(webpage, pattern, default=NO_DEFAULT):
337 assignments = self._search_regex(
338 pattern, webpage, 'encoded url', default=default)
342 assignments = assignments.split(';')
346 def parse_js_value(inp):
347 inp = re.sub(r'/\*(?:(?!\*/).)*?\*/', '', inp)
349 inps = inp.split('+')
350 return functools.reduce(
351 operator.concat, map(parse_js_value, inps))
355 return remove_quotes(inp)
357 for assn in assignments:
361 assn = re.sub(r'var\s+', '', assn)
362 vname, value = assn.split('=', 1)
363 js_vars[vname] = parse_js_value(value)
366 def add_video_url(video_url):
367 v_url = url_or_none(video_url)
370 if v_url in video_urls_set:
372 video_urls.append((v_url, None))
373 video_urls_set.add(v_url)
375 def parse_quality_items(quality_items):
376 q_items = self._parse_json(quality_items, video_id, fatal=False)
377 if not isinstance(q_items, list):
380 if isinstance(item, dict):
381 add_video_url(item.get('url'))
384 FORMAT_PREFIXES = ('media', 'quality', 'qualityItems')
385 js_vars = extract_js_vars(
386 webpage, r'(var\s+(?:%s)_.+)' % '|'.join(FORMAT_PREFIXES),
389 for key, format_url in js_vars.items():
390 if key.startswith(FORMAT_PREFIXES[-1]):
391 parse_quality_items(format_url)
392 elif any(key.startswith(p) for p in FORMAT_PREFIXES[:2]):
393 add_video_url(format_url)
394 if not video_urls and re.search(
395 r'<[^>]+\bid=["\']lockedPlayer
', webpage):
396 raise ExtractorError(
397 'Video
%s is locked
' % video_id, expected=True)
400 js_vars = extract_js_vars(
401 dl_webpage('tv
'), r'(var
.+?mediastring
.+?
)</script
>')
402 add_video_url(js_vars['mediastring
'])
404 for mobj in re.finditer(
405 r'<a
[^
>]+\bclass
=["\']downloadBtn\b[^>]+\bhref=(["\'])(?P
<url
>(?
:(?
!\
1).)+)\
1',
407 video_url = mobj.group('url
')
408 if video_url not in video_urls_set:
409 video_urls.append((video_url, None))
410 video_urls_set.add(video_url)
415 def add_format(format_url, height=None):
416 ext = determine_ext(format_url)
418 formats.extend(self._extract_mpd_formats(
419 format_url, video_id, mpd_id='dash
', fatal=False))
422 formats.extend(self._extract_m3u8_formats(
423 format_url, video_id, 'mp4
', entry_protocol='m3u8_native
',
424 m3u8_id='hls
', fatal=False))
427 height = int_or_none(self._search_regex(
428 r'(?P
<height
>\d
+)[pP
]?_\d
+[kK
]', format_url, 'height
',
432 'format_id
': format_field(height, template='%dp
'),
436 for video_url, height in video_urls:
438 upload_date = self._search_regex(
439 r'/(\d{6}
/\d{2}
)/', video_url, 'upload data
', default=None)
441 upload_date = upload_date.replace('/', '')
442 if '/video
/get_media
' in video_url:
443 medias = self._download_json(video_url, video_id, fatal=False)
444 if isinstance(medias, list):
446 if not isinstance(media, dict):
448 video_url = url_or_none(media.get('videoUrl
'))
451 height = int_or_none(media.get('quality
'))
452 add_format(video_url, height)
454 add_format(video_url)
456 # field_preference is unnecessary here, but kept for code-similarity with youtube-dl
458 formats, field_preference=('height
', 'width
', 'fps
', 'format_id
'))
460 video_uploader = self._html_search_regex(
461 r'(?s
)From
: 
;.+?
<(?
:a
\b[^
>]+\bhref
=["\']/(?:(?:user|channel)s|model|pornstar)/|span\b[^>]+\bclass=["\']username
)[^
>]+>(.+?
)<',
462 webpage, 'uploader
', default=None)
464 def extract_vote_count(kind, name):
465 return self._extract_count(
466 (r'<span
[^
>]+\bclass
="votes%s"[^
>]*>([\d
,\
.]+)</span
>' % kind,
467 r'<span
[^
>]+\bclass
=["\']votes%s["\'][^
>]*\bdata
-rating
=["\'](\d+)' % kind),
470 view_count = self._extract_count(
471 r'<span class="count
">([\d,\.]+)</span> [Vv]iews', webpage, 'view')
472 like_count = extract_vote_count('Up', 'like')
473 dislike_count = extract_vote_count('Down', 'dislike')
474 comment_count = self._extract_count(
475 r'All Comments\s*<span>\(([\d,.]+)\)', webpage, 'comment')
477 def extract_list(meta_key):
478 div = self._search_regex(
479 r'(?s)<div[^>]+\bclass=["\'].*?
\b%sWrapper
[^
>]*>(.+?
)</div
>'
480 % meta_key, webpage, meta_key, default=None)
482 return [clean_html(x).strip() for x in re.findall(r'(?s
)<a
[^
>]+\bhref
=[^
>]+>.+?
</a
>', div)]
484 info = self._search_json_ld(webpage, video_id, default={})
485 # description provided in JSON-LD is irrelevant
486 info['description
'] = None
490 'uploader
': video_uploader,
491 'upload_date
': upload_date,
493 'thumbnail
': thumbnail,
494 'duration
': duration,
495 'view_count
': view_count,
496 'like_count
': like_count,
497 'dislike_count
': dislike_count,
498 'comment_count
': comment_count,
501 'tags
': extract_list('tags
'),
502 'categories
': extract_list('categories
'),
503 'cast
': extract_list('pornstars
'),
504 'subtitles
': subtitles,
508 class PornHubPlaylistBaseIE(PornHubBaseIE):
509 def _extract_page(self, url):
510 return int_or_none(self._search_regex(
511 r'\bpage
=(\d
+)', url, 'page
', default=None))
513 def _extract_entries(self, webpage, host):
514 # Only process container div with main playlist content skipping
515 # drop-down menu that uses similar pattern for videos (see
516 # https://github.com/ytdl-org/youtube-dl/issues/11594).
517 container = self._search_regex(
518 r'(?s
)(<div
[^
>]+class=["\']container.+)', webpage,
519 'container', default=webpage)
523 'http://www.%s/%s' % (host, video_url),
524 PornHubIE.ie_key(), video_title=title)
525 for video_url, title in orderedSet(re.findall(
526 r'href="/?
(view_video\
.php
\?.*\bviewkey
=[\da
-z
]+[^
"]*)"[^
>]*\s
+title
="([^"]+)"',
531 class PornHubUserIE(PornHubPlaylistBaseIE):
532 _VALID_URL = r'(?P<url>https?://(?:[^/]+\.)?%s/(?:(?:user|channel)s|model|pornstar)/(?P<id>[^/?#&]+))(?:[?#&]|/(?!videos)|$)' % PornHubBaseIE._PORNHUB_HOST_RE
534 'url': 'https://www.pornhub.com/model/zoe_ph',
535 'playlist_mincount': 118,
537 'url': 'https://www.pornhub.com/pornstar/liz-vicious',
541 'playlist_mincount': 118,
543 'url': 'https://www.pornhub.com/users/russianveet69',
544 'only_matching': True,
546 'url': 'https://www.pornhub.com/channels/povd',
547 'only_matching': True,
549 'url': 'https://www.pornhub.com/model/zoe_ph?abc=1',
550 'only_matching': True,
552 # Unavailable via /videos page, but available with direct pagination
553 # on pornstar page (see [1]), requires premium
554 # 1. https://github.com/ytdl-org/youtube-dl/issues/27853
555 'url': 'https://www.pornhubpremium.com/pornstar/sienna-west',
556 'only_matching': True,
558 # Same as before, multi page
559 'url': 'https://www.pornhubpremium.com/pornstar/lily-labeau',
560 'only_matching': True,
562 'url': 'https://pornhubvybmsymdol4iibwgwtkpwmeyd6luq2gxajgjzfjvotyt5zhyd.onion/model/zoe_ph',
563 'only_matching': True,
566 def _real_extract(self, url):
567 mobj = self._match_valid_url(url)
568 user_id = mobj.group('id')
569 videos_url = '%s/videos' % mobj.group('url')
570 page = self._extract_page(url)
572 videos_url = update_url_query(videos_url, {'page': page})
573 return self.url_result(
574 videos_url, ie=PornHubPagedVideoListIE.ie_key(), video_id=user_id)
577 class PornHubPagedPlaylistBaseIE(PornHubPlaylistBaseIE):
579 def _has_more(webpage):
582 <li[^>]+\bclass=["\']page_next|
583 <link
[^
>]+\brel
=["\']next|
584 <button[^>]+\bid=["\']moreDataBtn
585 ''', webpage) is not None
587 def _entries(self, url, host, item_id):
588 page = self._extract_page(url)
592 def download_page(base_url, num, fallback=False):
593 note = 'Downloading page %d%s' % (num, ' (switch to fallback)' if fallback else '')
594 return self._download_webpage(
595 base_url, item_id, note, query={'page': num})
598 return isinstance(e.cause, compat_HTTPError) and e.cause.code == 404
601 has_page = page is not None
602 first_page = page if has_page else 1
603 for page_num in (first_page, ) if has_page else itertools.count(first_page):
606 webpage = download_page(base_url, page_num)
607 except ExtractorError as e:
608 # Some sources may not be available via /videos page,
609 # trying to fallback to main page pagination (see [1])
610 # 1. https://github.com/ytdl-org/youtube-dl/issues/27853
611 if is_404(e) and page_num == first_page and VIDEOS in base_url:
612 base_url = base_url.replace(VIDEOS, '')
613 webpage = download_page(base_url, page_num, fallback=True)
616 except ExtractorError as e:
617 if is_404(e) and page_num != first_page:
620 page_entries = self._extract_entries(webpage, host)
623 for e in page_entries:
625 if not self._has_more(webpage):
628 def _real_extract(self, url):
629 mobj = self._match_valid_url(url)
630 host = mobj.group('host')
631 item_id = mobj.group('id')
635 return self.playlist_result(self._entries(url, host, item_id), item_id)
638 class PornHubPagedVideoListIE(PornHubPagedPlaylistBaseIE):
639 _VALID_URL = r'https?://(?:[^/]+\.)?%s/(?!playlist/)(?P<id>(?:[^/]+/)*[^/?#&]+)' % PornHubBaseIE._PORNHUB_HOST_RE
641 'url': 'https://www.pornhub.com/model/zoe_ph/videos',
642 'only_matching': True,
644 'url': 'http://www.pornhub.com/users/rushandlia/videos',
645 'only_matching': True,
647 'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos',
649 'id': 'pornstar/jenny-blighe/videos',
651 'playlist_mincount': 149,
653 'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos?page=3',
655 'id': 'pornstar/jenny-blighe/videos',
657 'playlist_mincount': 40,
659 # default sorting as Top Rated Videos
660 'url': 'https://www.pornhub.com/channels/povd/videos',
662 'id': 'channels/povd/videos',
664 'playlist_mincount': 293,
667 'url': 'https://www.pornhub.com/channels/povd/videos?o=ra',
668 'only_matching': True,
671 'url': 'https://www.pornhub.com/channels/povd/videos?o=da',
672 'only_matching': True,
675 'url': 'https://www.pornhub.com/channels/povd/videos?o=vi',
676 'only_matching': True,
678 'url': 'http://www.pornhub.com/users/zoe_ph/videos/public',
679 'only_matching': True,
682 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=mv',
683 'only_matching': True,
686 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=tr',
687 'only_matching': True,
690 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=lg',
691 'only_matching': True,
694 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=cm',
695 'only_matching': True,
697 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos/paid',
698 'only_matching': True,
700 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos/fanonly',
701 'only_matching': True,
703 'url': 'https://www.pornhub.com/video',
704 'only_matching': True,
706 'url': 'https://www.pornhub.com/video?page=3',
707 'only_matching': True,
709 'url': 'https://www.pornhub.com/video/search?search=123',
710 'only_matching': True,
712 'url': 'https://www.pornhub.com/categories/teen',
713 'only_matching': True,
715 'url': 'https://www.pornhub.com/categories/teen?page=3',
716 'only_matching': True,
718 'url': 'https://www.pornhub.com/hd',
719 'only_matching': True,
721 'url': 'https://www.pornhub.com/hd?page=3',
722 'only_matching': True,
724 'url': 'https://www.pornhub.com/described-video',
725 'only_matching': True,
727 'url': 'https://www.pornhub.com/described-video?page=2',
728 'only_matching': True,
730 'url': 'https://www.pornhub.com/video/incategories/60fps-1/hd-porn',
731 'only_matching': True,
733 'url': 'https://pornhubvybmsymdol4iibwgwtkpwmeyd6luq2gxajgjzfjvotyt5zhyd.onion/model/zoe_ph/videos',
734 'only_matching': True,
738 def suitable(cls, url):
740 if PornHubIE.suitable(url) or PornHubUserIE.suitable(url) or PornHubUserVideosUploadIE.suitable(url)
741 else super(PornHubPagedVideoListIE, cls).suitable(url))
744 class PornHubUserVideosUploadIE(PornHubPagedPlaylistBaseIE):
745 _VALID_URL = r'(?P<url>https?://(?:[^/]+\.)?%s/(?:(?:user|channel)s|model|pornstar)/(?P<id>[^/]+)/videos/upload)' % PornHubBaseIE._PORNHUB_HOST_RE
747 'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos/upload',
749 'id': 'jenny-blighe',
751 'playlist_mincount': 129,
753 'url': 'https://www.pornhub.com/model/zoe_ph/videos/upload',
754 'only_matching': True,
756 'url': 'http://pornhubvybmsymdol4iibwgwtkpwmeyd6luq2gxajgjzfjvotyt5zhyd.onion/pornstar/jenny-blighe/videos/upload',
757 'only_matching': True,
761 class PornHubPlaylistIE(PornHubPlaylistBaseIE):
762 _VALID_URL = r'(?P<url>https?://(?:[^/]+\.)?%s/playlist/(?P<id>[^/?#&]+))' % PornHubBaseIE._PORNHUB_HOST_RE
764 'url': 'https://www.pornhub.com/playlist/44121572',
768 'playlist_count': 77,
770 'url': 'https://www.pornhub.com/playlist/4667351',
771 'only_matching': True,
773 'url': 'https://de.pornhub.com/playlist/4667351',
774 'only_matching': True,
776 'url': 'https://de.pornhub.com/playlist/4667351?page=2',
777 'only_matching': True,
780 def _entries(self, url, host, item_id):
781 webpage = self._download_webpage(url, item_id, 'Downloading page 1')
782 playlist_id = self._search_regex(r'var\s+playlistId\s*=\s*"([^"]+)"', webpage, 'playlist_id')
783 video_count = int_or_none(
784 self._search_regex(r'var\s+itemsCount\s*=\s*([0-9]+)\s*\|\|', webpage, 'video_count'))
785 token = self._search_regex(r'var\s+token\s*=\s*"([^"]+)"', webpage, 'token')
786 page_count = math.ceil((video_count - 36) / 40.) + 1
787 page_entries = self._extract_entries(webpage, host)
789 def download_page(page_num):
790 note = 'Downloading page {}'.format(page_num)
791 page_url = 'https://www.{}/playlist/viewChunked'.format(host)
792 return self._download_webpage(page_url, item_id, note, query={
798 for page_num in range(1, page_count + 1):
800 webpage = download_page(page_num)
801 page_entries = self._extract_entries(webpage, host)
804 for e in page_entries:
807 def _real_extract(self, url):
808 mobj = self._match_valid_url(url)
809 host = mobj.group('host')
810 item_id = mobj.group('id')
814 return self.playlist_result(self._entries(mobj.group('url'), host, item_id), item_id)