]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/pornhub.py
[cleanup] Revert unnecessary changes in 51d9739f8031fb37d8e25b0e9f1abea561e3d2e3
[yt-dlp.git] / yt_dlp / extractor / pornhub.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import functools
5 import itertools
6 import operator
7 import re
8
9 from .common import InfoExtractor
10 from ..compat import (
11 compat_HTTPError,
12 compat_str,
13 compat_urllib_request,
14 )
15 from .openload import PhantomJSwrapper
16 from ..utils import (
17 clean_html,
18 determine_ext,
19 ExtractorError,
20 int_or_none,
21 merge_dicts,
22 NO_DEFAULT,
23 orderedSet,
24 remove_quotes,
25 str_to_int,
26 update_url_query,
27 urlencode_postdata,
28 url_or_none,
29 )
30
31
32 class PornHubBaseIE(InfoExtractor):
33 _NETRC_MACHINE = 'pornhub'
34
35 def _download_webpage_handle(self, *args, **kwargs):
36 def dl(*args, **kwargs):
37 return super(PornHubBaseIE, self)._download_webpage_handle(*args, **kwargs)
38
39 ret = dl(*args, **kwargs)
40
41 if not ret:
42 return ret
43
44 webpage, urlh = ret
45
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)
53 else url_or_request)
54 phantom = PhantomJSwrapper(self, required_version='2.0')
55 phantom.get(url, html=webpage)
56 webpage, urlh = dl(*args, **kwargs)
57
58 return webpage, urlh
59
60 def _real_initialize(self):
61 self._logged_in = False
62
63 def _login(self, host):
64 if self._logged_in:
65 return
66
67 site = host.split('.')[0]
68
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)
76 if username is None:
77 return
78
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)
82
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*<'))
87
88 if is_logged(login_page):
89 self._logged_in = True
90 return
91
92 login_form = self._hidden_inputs(login_page)
93
94 login_form.update({
95 'username': username,
96 'password': password,
97 })
98
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),
103 headers={
104 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
105 'Referer': login_url,
106 'X-Requested-With': 'XMLHttpRequest',
107 })
108
109 if response.get('success') == '1':
110 self._logged_in = True
111 return
112
113 message = response.get('message')
114 if message is not None:
115 raise ExtractorError(
116 'Unable to login: %s' % message, expected=True)
117
118 raise ExtractorError('Unable to log in')
119
120
121 class PornHubIE(PornHubBaseIE):
122 IE_DESC = 'PornHub and Thumbzilla'
123 _VALID_URL = r'''(?x)
124 https?://
125 (?:
126 (?:[^/]+\.)?(?P<host>pornhub(?:premium)?\.(?:com|net|org))/(?:(?:view_video\.php|video/show)\?viewkey=|embed/)|
127 (?:www\.)?thumbzilla\.com/video/
128 )
129 (?P<id>[\da-z]+)
130 '''
131 _TESTS = [{
132 'url': 'http://www.pornhub.com/view_video.php?viewkey=648719015',
133 'md5': 'a6391306d050e4547f62b3f485dd9ba9',
134 'info_dict': {
135 'id': '648719015',
136 'ext': 'mp4',
137 'title': 'Seductive Indian beauty strips down and fingers her pink pussy',
138 'uploader': 'Babes',
139 'upload_date': '20130628',
140 'timestamp': 1372447216,
141 'duration': 361,
142 'view_count': int,
143 'like_count': int,
144 'dislike_count': int,
145 'comment_count': int,
146 'age_limit': 18,
147 'tags': list,
148 'categories': list,
149 'cast': list,
150 },
151 }, {
152 # non-ASCII title
153 'url': 'http://www.pornhub.com/view_video.php?viewkey=1331683002',
154 'info_dict': {
155 'id': '1331683002',
156 'ext': 'mp4',
157 'title': '重庆婷婷女王足交',
158 'upload_date': '20150213',
159 'timestamp': 1423804862,
160 'duration': 1753,
161 'view_count': int,
162 'like_count': int,
163 'dislike_count': int,
164 'comment_count': int,
165 'age_limit': 18,
166 'tags': list,
167 'categories': list,
168 },
169 'params': {
170 'skip_download': True,
171 },
172 'skip': 'Video has been flagged for verification in accordance with our trust and safety policy',
173 }, {
174 # subtitles
175 'url': 'https://www.pornhub.com/view_video.php?viewkey=ph5af5fef7c2aa7',
176 'info_dict': {
177 'id': 'ph5af5fef7c2aa7',
178 'ext': 'mp4',
179 'title': 'BFFS - Cute Teen Girls Share Cock On the Floor',
180 'uploader': 'BFFs',
181 'duration': 622,
182 'view_count': int,
183 'like_count': int,
184 'dislike_count': int,
185 'comment_count': int,
186 'age_limit': 18,
187 'tags': list,
188 'categories': list,
189 'subtitles': {
190 'en': [{
191 "ext": 'srt'
192 }]
193 },
194 },
195 'params': {
196 'skip_download': True,
197 },
198 'skip': 'This video has been disabled',
199 }, {
200 'url': 'http://www.pornhub.com/view_video.php?viewkey=ph557bbb6676d2d',
201 'only_matching': True,
202 }, {
203 # removed at the request of cam4.com
204 'url': 'http://fr.pornhub.com/view_video.php?viewkey=ph55ca2f9760862',
205 'only_matching': True,
206 }, {
207 # removed at the request of the copyright owner
208 'url': 'http://www.pornhub.com/view_video.php?viewkey=788152859',
209 'only_matching': True,
210 }, {
211 # removed by uploader
212 'url': 'http://www.pornhub.com/view_video.php?viewkey=ph572716d15a111',
213 'only_matching': True,
214 }, {
215 # private video
216 'url': 'http://www.pornhub.com/view_video.php?viewkey=ph56fd731fce6b7',
217 'only_matching': True,
218 }, {
219 'url': 'https://www.thumbzilla.com/video/ph56c6114abd99a/horny-girlfriend-sex',
220 'only_matching': True,
221 }, {
222 'url': 'http://www.pornhub.com/video/show?viewkey=648719015',
223 'only_matching': True,
224 }, {
225 'url': 'https://www.pornhub.net/view_video.php?viewkey=203640933',
226 'only_matching': True,
227 }, {
228 'url': 'https://www.pornhub.org/view_video.php?viewkey=203640933',
229 'only_matching': True,
230 }, {
231 'url': 'https://www.pornhubpremium.com/view_video.php?viewkey=ph5e4acdae54a82',
232 'only_matching': True,
233 }, {
234 # Some videos are available with the same id on both premium
235 # and non-premium sites (e.g. this and the following test)
236 'url': 'https://www.pornhub.com/view_video.php?viewkey=ph5f75b0f4b18e3',
237 'only_matching': True,
238 }, {
239 'url': 'https://www.pornhubpremium.com/view_video.php?viewkey=ph5f75b0f4b18e3',
240 'only_matching': True,
241 }]
242
243 @staticmethod
244 def _extract_urls(webpage):
245 return re.findall(
246 r'<iframe[^>]+?src=["\'](?P<url>(?:https?:)?//(?:www\.)?pornhub(?:premium)?\.(?:com|net|org)/embed/[\da-z]+)',
247 webpage)
248
249 def _extract_count(self, pattern, webpage, name):
250 return str_to_int(self._search_regex(
251 pattern, webpage, '%s count' % name, fatal=False))
252
253 def _real_extract(self, url):
254 mobj = re.match(self._VALID_URL, url)
255 host = mobj.group('host') or 'pornhub.com'
256 video_id = mobj.group('id')
257
258 self._login(host)
259
260 self._set_cookie(host, 'age_verified', '1')
261
262 def dl_webpage(platform):
263 self._set_cookie(host, 'platform', platform)
264 return self._download_webpage(
265 'https://www.%s/view_video.php?viewkey=%s' % (host, video_id),
266 video_id, 'Downloading %s webpage' % platform)
267
268 webpage = dl_webpage('pc')
269
270 error_msg = self._html_search_regex(
271 (r'(?s)<div[^>]+class=(["\'])(?:(?!\1).)*\b(?:removed|userMessageSection)\b(?:(?!\1).)*\1[^>]*>(?P<error>.+?)</div>',
272 r'(?s)<section[^>]+class=["\']noVideo["\'][^>]*>(?P<error>.+?)</section>'),
273 webpage, 'error message', default=None, group='error')
274 if error_msg:
275 error_msg = re.sub(r'\s+', ' ', error_msg)
276 raise ExtractorError(
277 'PornHub said: %s' % error_msg,
278 expected=True, video_id=video_id)
279
280 # video_title from flashvars contains whitespace instead of non-ASCII (see
281 # http://www.pornhub.com/view_video.php?viewkey=1331683002), not relying
282 # on that anymore.
283 title = self._html_search_meta(
284 'twitter:title', webpage, default=None) or self._html_search_regex(
285 (r'(?s)<h1[^>]+class=["\']title["\'][^>]*>(?P<title>.+?)</h1>',
286 r'<div[^>]+data-video-title=(["\'])(?P<title>(?:(?!\1).)+)\1',
287 r'shareTitle["\']\s*[=:]\s*(["\'])(?P<title>(?:(?!\1).)+)\1'),
288 webpage, 'title', group='title')
289
290 video_urls = []
291 video_urls_set = set()
292 subtitles = {}
293
294 flashvars = self._parse_json(
295 self._search_regex(
296 r'var\s+flashvars_\d+\s*=\s*({.+?});', webpage, 'flashvars', default='{}'),
297 video_id)
298 if flashvars:
299 subtitle_url = url_or_none(flashvars.get('closedCaptionsFile'))
300 if subtitle_url:
301 subtitles.setdefault('en', []).append({
302 'url': subtitle_url,
303 'ext': 'srt',
304 })
305 thumbnail = flashvars.get('image_url')
306 duration = int_or_none(flashvars.get('video_duration'))
307 media_definitions = flashvars.get('mediaDefinitions')
308 if isinstance(media_definitions, list):
309 for definition in media_definitions:
310 if not isinstance(definition, dict):
311 continue
312 video_url = definition.get('videoUrl')
313 if not video_url or not isinstance(video_url, compat_str):
314 continue
315 if video_url in video_urls_set:
316 continue
317 video_urls_set.add(video_url)
318 video_urls.append(
319 (video_url, int_or_none(definition.get('quality'))))
320 else:
321 thumbnail, duration = [None] * 2
322
323 def extract_js_vars(webpage, pattern, default=NO_DEFAULT):
324 assignments = self._search_regex(
325 pattern, webpage, 'encoded url', default=default)
326 if not assignments:
327 return {}
328
329 assignments = assignments.split(';')
330
331 js_vars = {}
332
333 def parse_js_value(inp):
334 inp = re.sub(r'/\*(?:(?!\*/).)*?\*/', '', inp)
335 if '+' in inp:
336 inps = inp.split('+')
337 return functools.reduce(
338 operator.concat, map(parse_js_value, inps))
339 inp = inp.strip()
340 if inp in js_vars:
341 return js_vars[inp]
342 return remove_quotes(inp)
343
344 for assn in assignments:
345 assn = assn.strip()
346 if not assn:
347 continue
348 assn = re.sub(r'var\s+', '', assn)
349 vname, value = assn.split('=', 1)
350 js_vars[vname] = parse_js_value(value)
351 return js_vars
352
353 def add_video_url(video_url):
354 v_url = url_or_none(video_url)
355 if not v_url:
356 return
357 if v_url in video_urls_set:
358 return
359 video_urls.append((v_url, None))
360 video_urls_set.add(v_url)
361
362 def parse_quality_items(quality_items):
363 q_items = self._parse_json(quality_items, video_id, fatal=False)
364 if not isinstance(q_items, list):
365 return
366 for item in q_items:
367 if isinstance(item, dict):
368 add_video_url(item.get('url'))
369
370 if not video_urls:
371 FORMAT_PREFIXES = ('media', 'quality', 'qualityItems')
372 js_vars = extract_js_vars(
373 webpage, r'(var\s+(?:%s)_.+)' % '|'.join(FORMAT_PREFIXES),
374 default=None)
375 if js_vars:
376 for key, format_url in js_vars.items():
377 if key.startswith(FORMAT_PREFIXES[-1]):
378 parse_quality_items(format_url)
379 elif any(key.startswith(p) for p in FORMAT_PREFIXES[:2]):
380 add_video_url(format_url)
381 if not video_urls and re.search(
382 r'<[^>]+\bid=["\']lockedPlayer', webpage):
383 raise ExtractorError(
384 'Video %s is locked' % video_id, expected=True)
385
386 if not video_urls:
387 js_vars = extract_js_vars(
388 dl_webpage('tv'), r'(var.+?mediastring.+?)</script>')
389 add_video_url(js_vars['mediastring'])
390
391 for mobj in re.finditer(
392 r'<a[^>]+\bclass=["\']downloadBtn\b[^>]+\bhref=(["\'])(?P<url>(?:(?!\1).)+)\1',
393 webpage):
394 video_url = mobj.group('url')
395 if video_url not in video_urls_set:
396 video_urls.append((video_url, None))
397 video_urls_set.add(video_url)
398
399 upload_date = None
400 formats = []
401
402 def add_format(format_url, height=None):
403 ext = determine_ext(format_url)
404 if ext == 'mpd':
405 formats.extend(self._extract_mpd_formats(
406 format_url, video_id, mpd_id='dash', fatal=False))
407 return
408 if ext == 'm3u8':
409 formats.extend(self._extract_m3u8_formats(
410 format_url, video_id, 'mp4', entry_protocol='m3u8_native',
411 m3u8_id='hls', fatal=False))
412 return
413 tbr = None
414 mobj = re.search(r'(?P<height>\d+)[pP]?_(?P<tbr>\d+)[kK]', format_url)
415 if mobj:
416 if not height:
417 height = int(mobj.group('height'))
418 tbr = int(mobj.group('tbr'))
419 formats.append({
420 'url': format_url,
421 'format_id': '%dp' % height if height else None,
422 'height': height,
423 'tbr': tbr,
424 })
425
426 for video_url, height in video_urls:
427 if not upload_date:
428 upload_date = self._search_regex(
429 r'/(\d{6}/\d{2})/', video_url, 'upload data', default=None)
430 if upload_date:
431 upload_date = upload_date.replace('/', '')
432 if '/video/get_media' in video_url:
433 medias = self._download_json(video_url, video_id, fatal=False)
434 if isinstance(medias, list):
435 for media in medias:
436 if not isinstance(media, dict):
437 continue
438 video_url = url_or_none(media.get('videoUrl'))
439 if not video_url:
440 continue
441 height = int_or_none(media.get('quality'))
442 add_format(video_url, height)
443 continue
444 add_format(video_url)
445 self._sort_formats(formats)
446
447 video_uploader = self._html_search_regex(
448 r'(?s)From:&nbsp;.+?<(?:a\b[^>]+\bhref=["\']/(?:(?:user|channel)s|model|pornstar)/|span\b[^>]+\bclass=["\']username)[^>]+>(.+?)<',
449 webpage, 'uploader', default=None)
450
451 def extract_vote_count(kind, name):
452 return self._extract_count(
453 (r'<span[^>]+\bclass="votes%s"[^>]*>([\d,\.]+)</span>' % kind,
454 r'<span[^>]+\bclass=["\']votes%s["\'][^>]*\bdata-rating=["\'](\d+)' % kind),
455 webpage, name)
456
457 view_count = self._extract_count(
458 r'<span class="count">([\d,\.]+)</span> [Vv]iews', webpage, 'view')
459 like_count = extract_vote_count('Up', 'like')
460 dislike_count = extract_vote_count('Down', 'dislike')
461 comment_count = self._extract_count(
462 r'All Comments\s*<span>\(([\d,.]+)\)', webpage, 'comment')
463
464 def extract_list(meta_key):
465 div = self._search_regex(
466 r'(?s)<div[^>]+\bclass=["\'].*?\b%sWrapper[^>]*>(.+?)</div>'
467 % meta_key, webpage, meta_key, default=None)
468 if div:
469 return [clean_html(x).strip() for x in re.findall(r'(?s)<a[^>]+\bhref=[^>]+>.+?</a>', div)]
470
471 info = self._search_json_ld(webpage, video_id, default={})
472 # description provided in JSON-LD is irrelevant
473 info['description'] = None
474
475 return merge_dicts({
476 'id': video_id,
477 'uploader': video_uploader,
478 'upload_date': upload_date,
479 'title': title,
480 'thumbnail': thumbnail,
481 'duration': duration,
482 'view_count': view_count,
483 'like_count': like_count,
484 'dislike_count': dislike_count,
485 'comment_count': comment_count,
486 'formats': formats,
487 'age_limit': 18,
488 'tags': extract_list('tags'),
489 'categories': extract_list('categories'),
490 'cast': extract_list('pornstars'),
491 'subtitles': subtitles,
492 }, info)
493
494
495 class PornHubPlaylistBaseIE(PornHubBaseIE):
496 def _extract_page(self, url):
497 return int_or_none(self._search_regex(
498 r'\bpage=(\d+)', url, 'page', default=None))
499
500 def _extract_entries(self, webpage, host):
501 # Only process container div with main playlist content skipping
502 # drop-down menu that uses similar pattern for videos (see
503 # https://github.com/ytdl-org/youtube-dl/issues/11594).
504 container = self._search_regex(
505 r'(?s)(<div[^>]+class=["\']container.+)', webpage,
506 'container', default=webpage)
507
508 return [
509 self.url_result(
510 'http://www.%s/%s' % (host, video_url),
511 PornHubIE.ie_key(), video_title=title)
512 for video_url, title in orderedSet(re.findall(
513 r'href="/?(view_video\.php\?.*\bviewkey=[\da-z]+[^"]*)"[^>]*\s+title="([^"]+)"',
514 container))
515 ]
516
517
518 class PornHubUserIE(PornHubPlaylistBaseIE):
519 _VALID_URL = r'(?P<url>https?://(?:[^/]+\.)?(?P<host>pornhub(?:premium)?\.(?:com|net|org))/(?:(?:user|channel)s|model|pornstar)/(?P<id>[^/?#&]+))(?:[?#&]|/(?!videos)|$)'
520 _TESTS = [{
521 'url': 'https://www.pornhub.com/model/zoe_ph',
522 'playlist_mincount': 118,
523 }, {
524 'url': 'https://www.pornhub.com/pornstar/liz-vicious',
525 'info_dict': {
526 'id': 'liz-vicious',
527 },
528 'playlist_mincount': 118,
529 }, {
530 'url': 'https://www.pornhub.com/users/russianveet69',
531 'only_matching': True,
532 }, {
533 'url': 'https://www.pornhub.com/channels/povd',
534 'only_matching': True,
535 }, {
536 'url': 'https://www.pornhub.com/model/zoe_ph?abc=1',
537 'only_matching': True,
538 }, {
539 # Unavailable via /videos page, but available with direct pagination
540 # on pornstar page (see [1]), requires premium
541 # 1. https://github.com/ytdl-org/youtube-dl/issues/27853
542 'url': 'https://www.pornhubpremium.com/pornstar/sienna-west',
543 'only_matching': True,
544 }, {
545 # Same as before, multi page
546 'url': 'https://www.pornhubpremium.com/pornstar/lily-labeau',
547 'only_matching': True,
548 }]
549
550 def _real_extract(self, url):
551 mobj = re.match(self._VALID_URL, url)
552 user_id = mobj.group('id')
553 videos_url = '%s/videos' % mobj.group('url')
554 page = self._extract_page(url)
555 if page:
556 videos_url = update_url_query(videos_url, {'page': page})
557 return self.url_result(
558 videos_url, ie=PornHubPagedVideoListIE.ie_key(), video_id=user_id)
559
560
561 class PornHubPagedPlaylistBaseIE(PornHubPlaylistBaseIE):
562 @staticmethod
563 def _has_more(webpage):
564 return re.search(
565 r'''(?x)
566 <li[^>]+\bclass=["\']page_next|
567 <link[^>]+\brel=["\']next|
568 <button[^>]+\bid=["\']moreDataBtn
569 ''', webpage) is not None
570
571 def _entries(self, url, host, item_id):
572 page = self._extract_page(url)
573
574 VIDEOS = '/videos'
575
576 def download_page(base_url, num, fallback=False):
577 note = 'Downloading page %d%s' % (num, ' (switch to fallback)' if fallback else '')
578 return self._download_webpage(
579 base_url, item_id, note, query={'page': num})
580
581 def is_404(e):
582 return isinstance(e.cause, compat_HTTPError) and e.cause.code == 404
583
584 base_url = url
585 has_page = page is not None
586 first_page = page if has_page else 1
587 for page_num in (first_page, ) if has_page else itertools.count(first_page):
588 try:
589 try:
590 webpage = download_page(base_url, page_num)
591 except ExtractorError as e:
592 # Some sources may not be available via /videos page,
593 # trying to fallback to main page pagination (see [1])
594 # 1. https://github.com/ytdl-org/youtube-dl/issues/27853
595 if is_404(e) and page_num == first_page and VIDEOS in base_url:
596 base_url = base_url.replace(VIDEOS, '')
597 webpage = download_page(base_url, page_num, fallback=True)
598 else:
599 raise
600 except ExtractorError as e:
601 if is_404(e) and page_num != first_page:
602 break
603 raise
604 page_entries = self._extract_entries(webpage, host)
605 if not page_entries:
606 break
607 for e in page_entries:
608 yield e
609 if not self._has_more(webpage):
610 break
611
612 def _real_extract(self, url):
613 mobj = re.match(self._VALID_URL, url)
614 host = mobj.group('host')
615 item_id = mobj.group('id')
616
617 self._login(host)
618
619 return self.playlist_result(self._entries(url, host, item_id), item_id)
620
621
622 class PornHubPagedVideoListIE(PornHubPagedPlaylistBaseIE):
623 _VALID_URL = r'https?://(?:[^/]+\.)?(?P<host>pornhub(?:premium)?\.(?:com|net|org))/(?P<id>(?:[^/]+/)*[^/?#&]+)'
624 _TESTS = [{
625 'url': 'https://www.pornhub.com/model/zoe_ph/videos',
626 'only_matching': True,
627 }, {
628 'url': 'http://www.pornhub.com/users/rushandlia/videos',
629 'only_matching': True,
630 }, {
631 'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos',
632 'info_dict': {
633 'id': 'pornstar/jenny-blighe/videos',
634 },
635 'playlist_mincount': 149,
636 }, {
637 'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos?page=3',
638 'info_dict': {
639 'id': 'pornstar/jenny-blighe/videos',
640 },
641 'playlist_mincount': 40,
642 }, {
643 # default sorting as Top Rated Videos
644 'url': 'https://www.pornhub.com/channels/povd/videos',
645 'info_dict': {
646 'id': 'channels/povd/videos',
647 },
648 'playlist_mincount': 293,
649 }, {
650 # Top Rated Videos
651 'url': 'https://www.pornhub.com/channels/povd/videos?o=ra',
652 'only_matching': True,
653 }, {
654 # Most Recent Videos
655 'url': 'https://www.pornhub.com/channels/povd/videos?o=da',
656 'only_matching': True,
657 }, {
658 # Most Viewed Videos
659 'url': 'https://www.pornhub.com/channels/povd/videos?o=vi',
660 'only_matching': True,
661 }, {
662 'url': 'http://www.pornhub.com/users/zoe_ph/videos/public',
663 'only_matching': True,
664 }, {
665 # Most Viewed Videos
666 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=mv',
667 'only_matching': True,
668 }, {
669 # Top Rated Videos
670 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=tr',
671 'only_matching': True,
672 }, {
673 # Longest Videos
674 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=lg',
675 'only_matching': True,
676 }, {
677 # Newest Videos
678 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=cm',
679 'only_matching': True,
680 }, {
681 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos/paid',
682 'only_matching': True,
683 }, {
684 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos/fanonly',
685 'only_matching': True,
686 }, {
687 'url': 'https://www.pornhub.com/video',
688 'only_matching': True,
689 }, {
690 'url': 'https://www.pornhub.com/video?page=3',
691 'only_matching': True,
692 }, {
693 'url': 'https://www.pornhub.com/video/search?search=123',
694 'only_matching': True,
695 }, {
696 'url': 'https://www.pornhub.com/categories/teen',
697 'only_matching': True,
698 }, {
699 'url': 'https://www.pornhub.com/categories/teen?page=3',
700 'only_matching': True,
701 }, {
702 'url': 'https://www.pornhub.com/hd',
703 'only_matching': True,
704 }, {
705 'url': 'https://www.pornhub.com/hd?page=3',
706 'only_matching': True,
707 }, {
708 'url': 'https://www.pornhub.com/described-video',
709 'only_matching': True,
710 }, {
711 'url': 'https://www.pornhub.com/described-video?page=2',
712 'only_matching': True,
713 }, {
714 'url': 'https://www.pornhub.com/video/incategories/60fps-1/hd-porn',
715 'only_matching': True,
716 }, {
717 'url': 'https://www.pornhub.com/playlist/44121572',
718 'info_dict': {
719 'id': 'playlist/44121572',
720 },
721 'playlist_mincount': 132,
722 }, {
723 'url': 'https://www.pornhub.com/playlist/4667351',
724 'only_matching': True,
725 }, {
726 'url': 'https://de.pornhub.com/playlist/4667351',
727 'only_matching': True,
728 }]
729
730 @classmethod
731 def suitable(cls, url):
732 return (False
733 if PornHubIE.suitable(url) or PornHubUserIE.suitable(url) or PornHubUserVideosUploadIE.suitable(url)
734 else super(PornHubPagedVideoListIE, cls).suitable(url))
735
736
737 class PornHubUserVideosUploadIE(PornHubPagedPlaylistBaseIE):
738 _VALID_URL = r'(?P<url>https?://(?:[^/]+\.)?(?P<host>pornhub(?:premium)?\.(?:com|net|org))/(?:(?:user|channel)s|model|pornstar)/(?P<id>[^/]+)/videos/upload)'
739 _TESTS = [{
740 'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos/upload',
741 'info_dict': {
742 'id': 'jenny-blighe',
743 },
744 'playlist_mincount': 129,
745 }, {
746 'url': 'https://www.pornhub.com/model/zoe_ph/videos/upload',
747 'only_matching': True,
748 }]