]>
Commit | Line | Data |
---|---|---|
6c376029 | 1 | # coding: utf-8 |
9933b574 PH |
2 | from __future__ import unicode_literals |
3 | ||
21fbf0f9 | 4 | import functools |
34541395 | 5 | import itertools |
21fbf0f9 | 6 | import operator |
125cfd78 | 7 | import re |
8 | ||
9 | from .common import InfoExtractor | |
1cc79574 | 10 | from ..compat import ( |
34541395 | 11 | compat_HTTPError, |
79367a98 | 12 | compat_str, |
278d061a | 13 | compat_urllib_request, |
1cc79574 | 14 | ) |
278d061a | 15 | from .openload import PhantomJSwrapper |
1cc79574 | 16 | from ..utils import ( |
b8526c78 | 17 | determine_ext, |
50789175 | 18 | ExtractorError, |
ed8648a3 | 19 | int_or_none, |
0164cd5d | 20 | NO_DEFAULT, |
8f9a477e | 21 | orderedSet, |
e1e35d1a | 22 | remove_quotes, |
0320ddc1 | 23 | str_to_int, |
4938c8d5 | 24 | url_or_none, |
125cfd78 | 25 | ) |
125cfd78 | 26 | |
9933b574 | 27 | |
71a1f617 S |
28 | class PornHubBaseIE(InfoExtractor): |
29 | def _download_webpage_handle(self, *args, **kwargs): | |
30 | def dl(*args, **kwargs): | |
31 | return super(PornHubBaseIE, self)._download_webpage_handle(*args, **kwargs) | |
32 | ||
33 | webpage, urlh = dl(*args, **kwargs) | |
34 | ||
35 | if any(re.search(p, webpage) for p in ( | |
36 | r'<body\b[^>]+\bonload=["\']go\(\)', | |
37 | r'document\.cookie\s*=\s*["\']RNKEY=', | |
38 | r'document\.location\.reload\(true\)')): | |
39 | url_or_request = args[0] | |
40 | url = (url_or_request.get_full_url() | |
41 | if isinstance(url_or_request, compat_urllib_request.Request) | |
42 | else url_or_request) | |
43 | phantom = PhantomJSwrapper(self, required_version='2.0') | |
44 | phantom.get(url, html=webpage) | |
45 | webpage, urlh = dl(*args, **kwargs) | |
46 | ||
47 | return webpage, urlh | |
48 | ||
49 | ||
50 | class PornHubIE(PornHubBaseIE): | |
bc4b2d75 S |
51 | IE_DESC = 'PornHub and Thumbzilla' |
52 | _VALID_URL = r'''(?x) | |
53 | https?:// | |
54 | (?: | |
3430ff9b | 55 | (?:[^/]+\.)?(?P<host>pornhub\.(?:com|net))/(?:(?:view_video\.php|video/show)\?viewkey=|embed/)| |
bc4b2d75 S |
56 | (?:www\.)?thumbzilla\.com/video/ |
57 | ) | |
b52c9ef1 | 58 | (?P<id>[\da-z]+) |
bc4b2d75 | 59 | ''' |
360075e2 | 60 | _TESTS = [{ |
9933b574 | 61 | 'url': 'http://www.pornhub.com/view_video.php?viewkey=648719015', |
ed8648a3 | 62 | 'md5': '1e19b41231a02eba417839222ac9d58e', |
9933b574 | 63 | 'info_dict': { |
249efaf4 PH |
64 | 'id': '648719015', |
65 | 'ext': 'mp4', | |
611c1dd9 | 66 | 'title': 'Seductive Indian beauty strips down and fingers her pink pussy', |
ed8648a3 | 67 | 'uploader': 'Babes', |
3661ebf2 | 68 | 'upload_date': '20130628', |
ed8648a3 S |
69 | 'duration': 361, |
70 | 'view_count': int, | |
71 | 'like_count': int, | |
72 | 'dislike_count': int, | |
73 | 'comment_count': int, | |
74 | 'age_limit': 18, | |
6bb05b32 YCH |
75 | 'tags': list, |
76 | 'categories': list, | |
6c376029 S |
77 | }, |
78 | }, { | |
79 | # non-ASCII title | |
80 | 'url': 'http://www.pornhub.com/view_video.php?viewkey=1331683002', | |
81 | 'info_dict': { | |
82 | 'id': '1331683002', | |
83 | 'ext': 'mp4', | |
84 | 'title': '重庆婷婷女王足交', | |
79367a98 | 85 | 'uploader': 'Unknown', |
3661ebf2 | 86 | 'upload_date': '20150213', |
6c376029 S |
87 | 'duration': 1753, |
88 | 'view_count': int, | |
89 | 'like_count': int, | |
90 | 'dislike_count': int, | |
91 | 'comment_count': int, | |
92 | 'age_limit': 18, | |
6bb05b32 YCH |
93 | 'tags': list, |
94 | 'categories': list, | |
6c376029 S |
95 | }, |
96 | 'params': { | |
97 | 'skip_download': True, | |
98 | }, | |
4938c8d5 GF |
99 | }, { |
100 | # subtitles | |
101 | 'url': 'https://www.pornhub.com/view_video.php?viewkey=ph5af5fef7c2aa7', | |
102 | 'info_dict': { | |
103 | 'id': 'ph5af5fef7c2aa7', | |
104 | 'ext': 'mp4', | |
105 | 'title': 'BFFS - Cute Teen Girls Share Cock On the Floor', | |
106 | 'uploader': 'BFFs', | |
107 | 'duration': 622, | |
108 | 'view_count': int, | |
109 | 'like_count': int, | |
110 | 'dislike_count': int, | |
111 | 'comment_count': int, | |
112 | 'age_limit': 18, | |
113 | 'tags': list, | |
114 | 'categories': list, | |
115 | 'subtitles': { | |
116 | 'en': [{ | |
117 | "ext": 'srt' | |
118 | }] | |
119 | }, | |
120 | }, | |
121 | 'params': { | |
122 | 'skip_download': True, | |
123 | }, | |
360075e2 S |
124 | }, { |
125 | 'url': 'http://www.pornhub.com/view_video.php?viewkey=ph557bbb6676d2d', | |
126 | 'only_matching': True, | |
272e4db5 | 127 | }, { |
eaaaaec0 | 128 | # removed at the request of cam4.com |
272e4db5 S |
129 | 'url': 'http://fr.pornhub.com/view_video.php?viewkey=ph55ca2f9760862', |
130 | 'only_matching': True, | |
eaaaaec0 S |
131 | }, { |
132 | # removed at the request of the copyright owner | |
133 | 'url': 'http://www.pornhub.com/view_video.php?viewkey=788152859', | |
134 | 'only_matching': True, | |
135 | }, { | |
136 | # removed by uploader | |
137 | 'url': 'http://www.pornhub.com/view_video.php?viewkey=ph572716d15a111', | |
138 | 'only_matching': True, | |
195f0845 S |
139 | }, { |
140 | # private video | |
141 | 'url': 'http://www.pornhub.com/view_video.php?viewkey=ph56fd731fce6b7', | |
142 | 'only_matching': True, | |
bc4b2d75 S |
143 | }, { |
144 | 'url': 'https://www.thumbzilla.com/video/ph56c6114abd99a/horny-girlfriend-sex', | |
145 | 'only_matching': True, | |
a99cc4ca S |
146 | }, { |
147 | 'url': 'http://www.pornhub.com/video/show?viewkey=648719015', | |
148 | 'only_matching': True, | |
f97c0991 S |
149 | }, { |
150 | 'url': 'https://www.pornhub.net/view_video.php?viewkey=203640933', | |
151 | 'only_matching': True, | |
360075e2 | 152 | }] |
125cfd78 | 153 | |
b52c9ef1 S |
154 | @staticmethod |
155 | def _extract_urls(webpage): | |
156 | return re.findall( | |
3430ff9b | 157 | r'<iframe[^>]+?src=["\'](?P<url>(?:https?:)?//(?:www\.)?pornhub\.(?:com|net)/embed/[\da-z]+)', |
b52c9ef1 | 158 | webpage) |
65d161c4 | 159 | |
0320ddc1 | 160 | def _extract_count(self, pattern, webpage, name): |
7700207e S |
161 | return str_to_int(self._search_regex( |
162 | pattern, webpage, '%s count' % name, fatal=False)) | |
0320ddc1 | 163 | |
125cfd78 | 164 | def _real_extract(self, url): |
3430ff9b S |
165 | mobj = re.match(self._VALID_URL, url) |
166 | host = mobj.group('host') or 'pornhub.com' | |
167 | video_id = mobj.group('id') | |
7399ca1f | 168 | |
3430ff9b | 169 | self._set_cookie(host, 'age_verified', '1') |
125cfd78 | 170 | |
9a372f14 | 171 | def dl_webpage(platform): |
3430ff9b | 172 | self._set_cookie(host, 'platform', platform) |
9a372f14 | 173 | return self._download_webpage( |
2c53c0eb | 174 | 'https://www.%s/view_video.php?viewkey=%s' % (host, video_id), |
79367a98 | 175 | video_id, 'Downloading %s webpage' % platform) |
9a372f14 S |
176 | |
177 | webpage = dl_webpage('pc') | |
125cfd78 | 178 | |
50789175 | 179 | error_msg = self._html_search_regex( |
add7d2a0 | 180 | r'(?s)<div[^>]+class=(["\'])(?:(?!\1).)*\b(?:removed|userMessageSection)\b(?:(?!\1).)*\1[^>]*>(?P<error>.+?)</div>', |
3cb3b600 | 181 | webpage, 'error message', default=None, group='error') |
50789175 PH |
182 | if error_msg: |
183 | error_msg = re.sub(r'\s+', ' ', error_msg) | |
184 | raise ExtractorError( | |
185 | 'PornHub said: %s' % error_msg, | |
186 | expected=True, video_id=video_id) | |
187 | ||
6c376029 S |
188 | # video_title from flashvars contains whitespace instead of non-ASCII (see |
189 | # http://www.pornhub.com/view_video.php?viewkey=1331683002), not relying | |
190 | # on that anymore. | |
79367a98 | 191 | title = self._html_search_meta( |
6c376029 S |
192 | 'twitter:title', webpage, default=None) or self._search_regex( |
193 | (r'<h1[^>]+class=["\']title["\'][^>]*>(?P<title>[^<]+)', | |
194 | r'<div[^>]+data-video-title=(["\'])(?P<title>.+?)\1', | |
195 | r'shareTitle\s*=\s*(["\'])(?P<title>.+?)\1'), | |
196 | webpage, 'title', group='title') | |
197 | ||
79367a98 S |
198 | video_urls = [] |
199 | video_urls_set = set() | |
4938c8d5 | 200 | subtitles = {} |
79367a98 | 201 | |
ed8648a3 S |
202 | flashvars = self._parse_json( |
203 | self._search_regex( | |
03442072 | 204 | r'var\s+flashvars_\d+\s*=\s*({.+?});', webpage, 'flashvars', default='{}'), |
ed8648a3 S |
205 | video_id) |
206 | if flashvars: | |
4938c8d5 GF |
207 | subtitle_url = url_or_none(flashvars.get('closedCaptionsFile')) |
208 | if subtitle_url: | |
209 | subtitles.setdefault('en', []).append({ | |
210 | 'url': subtitle_url, | |
211 | 'ext': 'srt', | |
212 | }) | |
ed8648a3 S |
213 | thumbnail = flashvars.get('image_url') |
214 | duration = int_or_none(flashvars.get('video_duration')) | |
79367a98 S |
215 | media_definitions = flashvars.get('mediaDefinitions') |
216 | if isinstance(media_definitions, list): | |
217 | for definition in media_definitions: | |
218 | if not isinstance(definition, dict): | |
219 | continue | |
220 | video_url = definition.get('videoUrl') | |
221 | if not video_url or not isinstance(video_url, compat_str): | |
222 | continue | |
223 | if video_url in video_urls_set: | |
224 | continue | |
225 | video_urls_set.add(video_url) | |
226 | video_urls.append( | |
227 | (video_url, int_or_none(definition.get('quality')))) | |
ed8648a3 | 228 | else: |
79367a98 S |
229 | thumbnail, duration = [None] * 2 |
230 | ||
0164cd5d | 231 | def extract_js_vars(webpage, pattern, default=NO_DEFAULT): |
79367a98 | 232 | assignments = self._search_regex( |
0164cd5d | 233 | pattern, webpage, 'encoded url', default=default) |
f4134726 S |
234 | if not assignments: |
235 | return {} | |
236 | ||
237 | assignments = assignments.split(';') | |
79367a98 S |
238 | |
239 | js_vars = {} | |
240 | ||
241 | def parse_js_value(inp): | |
242 | inp = re.sub(r'/\*(?:(?!\*/).)*?\*/', '', inp) | |
243 | if '+' in inp: | |
244 | inps = inp.split('+') | |
245 | return functools.reduce( | |
246 | operator.concat, map(parse_js_value, inps)) | |
247 | inp = inp.strip() | |
248 | if inp in js_vars: | |
249 | return js_vars[inp] | |
250 | return remove_quotes(inp) | |
251 | ||
252 | for assn in assignments: | |
253 | assn = assn.strip() | |
254 | if not assn: | |
255 | continue | |
256 | assn = re.sub(r'var\s+', '', assn) | |
257 | vname, value = assn.split('=', 1) | |
258 | js_vars[vname] = parse_js_value(value) | |
f4134726 | 259 | return js_vars |
79367a98 | 260 | |
f4134726 S |
261 | def add_video_url(video_url): |
262 | v_url = url_or_none(video_url) | |
263 | if not v_url: | |
264 | return | |
265 | if v_url in video_urls_set: | |
266 | return | |
267 | video_urls.append((v_url, None)) | |
268 | video_urls_set.add(v_url) | |
269 | ||
270 | if not video_urls: | |
271 | FORMAT_PREFIXES = ('media', 'quality') | |
272 | js_vars = extract_js_vars( | |
273 | webpage, r'(var\s+(?:%s)_.+)' % '|'.join(FORMAT_PREFIXES), | |
0164cd5d | 274 | default=None) |
f4134726 S |
275 | if js_vars: |
276 | for key, format_url in js_vars.items(): | |
277 | if any(key.startswith(p) for p in FORMAT_PREFIXES): | |
278 | add_video_url(format_url) | |
0164cd5d S |
279 | if not video_urls and re.search( |
280 | r'<[^>]+\bid=["\']lockedPlayer', webpage): | |
281 | raise ExtractorError( | |
282 | 'Video %s is locked' % video_id, expected=True) | |
f4134726 S |
283 | |
284 | if not video_urls: | |
285 | js_vars = extract_js_vars( | |
286 | dl_webpage('tv'), r'(var.+?mediastring.+?)</script>') | |
287 | add_video_url(js_vars['mediastring']) | |
79367a98 S |
288 | |
289 | for mobj in re.finditer( | |
290 | r'<a[^>]+\bclass=["\']downloadBtn\b[^>]+\bhref=(["\'])(?P<url>(?:(?!\1).)+)\1', | |
291 | webpage): | |
292 | video_url = mobj.group('url') | |
293 | if video_url not in video_urls_set: | |
294 | video_urls.append((video_url, None)) | |
295 | video_urls_set.add(video_url) | |
296 | ||
3661ebf2 | 297 | upload_date = None |
79367a98 S |
298 | formats = [] |
299 | for video_url, height in video_urls: | |
3661ebf2 S |
300 | if not upload_date: |
301 | upload_date = self._search_regex( | |
302 | r'/(\d{6}/\d{2})/', video_url, 'upload data', default=None) | |
303 | if upload_date: | |
304 | upload_date = upload_date.replace('/', '') | |
f4134726 S |
305 | ext = determine_ext(video_url) |
306 | if ext == 'mpd': | |
b8526c78 S |
307 | formats.extend(self._extract_mpd_formats( |
308 | video_url, video_id, mpd_id='dash', fatal=False)) | |
309 | continue | |
f4134726 S |
310 | elif ext == 'm3u8': |
311 | formats.extend(self._extract_m3u8_formats( | |
312 | video_url, video_id, 'mp4', entry_protocol='m3u8_native', | |
313 | m3u8_id='hls', fatal=False)) | |
314 | continue | |
79367a98 S |
315 | tbr = None |
316 | mobj = re.search(r'(?P<height>\d+)[pP]?_(?P<tbr>\d+)[kK]', video_url) | |
317 | if mobj: | |
318 | if not height: | |
319 | height = int(mobj.group('height')) | |
320 | tbr = int(mobj.group('tbr')) | |
321 | formats.append({ | |
322 | 'url': video_url, | |
323 | 'format_id': '%dp' % height if height else None, | |
324 | 'height': height, | |
325 | 'tbr': tbr, | |
326 | }) | |
327 | self._sort_formats(formats) | |
ed8648a3 | 328 | |
0320ddc1 | 329 | video_uploader = self._html_search_regex( |
2d4fe594 | 330 | r'(?s)From: .+?<(?:a\b[^>]+\bhref=["\']/(?:(?:user|channel)s|model|pornstar)/|span\b[^>]+\bclass=["\']username)[^>]+>(.+?)<', |
0320ddc1 | 331 | webpage, 'uploader', fatal=False) |
125cfd78 | 332 | |
7700207e S |
333 | view_count = self._extract_count( |
334 | r'<span class="count">([\d,\.]+)</span> views', webpage, 'view') | |
335 | like_count = self._extract_count( | |
336 | r'<span class="votesUp">([\d,\.]+)</span>', webpage, 'like') | |
337 | dislike_count = self._extract_count( | |
338 | r'<span class="votesDown">([\d,\.]+)</span>', webpage, 'dislike') | |
0320ddc1 | 339 | comment_count = self._extract_count( |
7700207e | 340 | r'All Comments\s*<span>\(([\d,.]+)\)', webpage, 'comment') |
0320ddc1 | 341 | |
5dda1ede | 342 | def extract_list(meta_key): |
d2d970d0 | 343 | div = self._search_regex( |
5dda1ede S |
344 | r'(?s)<div[^>]+\bclass=["\'].*?\b%sWrapper[^>]*>(.+?)</div>' |
345 | % meta_key, webpage, meta_key, default=None) | |
d2d970d0 | 346 | if div: |
5dda1ede | 347 | return re.findall(r'<a[^>]+\bhref=[^>]+>([^<]+)', div) |
6bb05b32 | 348 | |
125cfd78 | 349 | return { |
350 | 'id': video_id, | |
351 | 'uploader': video_uploader, | |
3661ebf2 | 352 | 'upload_date': upload_date, |
6c376029 | 353 | 'title': title, |
125cfd78 | 354 | 'thumbnail': thumbnail, |
ed8648a3 | 355 | 'duration': duration, |
0320ddc1 S |
356 | 'view_count': view_count, |
357 | 'like_count': like_count, | |
358 | 'dislike_count': dislike_count, | |
359 | 'comment_count': comment_count, | |
79367a98 | 360 | 'formats': formats, |
750e9833 | 361 | 'age_limit': 18, |
5dda1ede S |
362 | 'tags': extract_list('tags'), |
363 | 'categories': extract_list('categories'), | |
4938c8d5 | 364 | 'subtitles': subtitles, |
125cfd78 | 365 | } |
e66e1a00 S |
366 | |
367 | ||
71a1f617 | 368 | class PornHubPlaylistBaseIE(PornHubBaseIE): |
3430ff9b | 369 | def _extract_entries(self, webpage, host): |
475bcb22 S |
370 | # Only process container div with main playlist content skipping |
371 | # drop-down menu that uses similar pattern for videos (see | |
067aa17e | 372 | # https://github.com/ytdl-org/youtube-dl/issues/11594). |
475bcb22 S |
373 | container = self._search_regex( |
374 | r'(?s)(<div[^>]+class=["\']container.+)', webpage, | |
375 | 'container', default=webpage) | |
376 | ||
40e146aa | 377 | return [ |
3a23bae9 | 378 | self.url_result( |
3430ff9b | 379 | 'http://www.%s/%s' % (host, video_url), |
3a23bae9 S |
380 | PornHubIE.ie_key(), video_title=title) |
381 | for video_url, title in orderedSet(re.findall( | |
382 | r'href="/?(view_video\.php\?.*\bviewkey=[\da-z]+[^"]*)"[^>]*\s+title="([^"]+)"', | |
475bcb22 | 383 | container)) |
40e146aa | 384 | ] |
e66e1a00 S |
385 | |
386 | def _real_extract(self, url): | |
3430ff9b S |
387 | mobj = re.match(self._VALID_URL, url) |
388 | host = mobj.group('host') | |
389 | playlist_id = mobj.group('id') | |
e66e1a00 S |
390 | |
391 | webpage = self._download_webpage(url, playlist_id) | |
392 | ||
3430ff9b | 393 | entries = self._extract_entries(webpage, host) |
e66e1a00 S |
394 | |
395 | playlist = self._parse_json( | |
396 | self._search_regex( | |
cd138d8b S |
397 | r'(?:playlistObject|PLAYLIST_VIEW)\s*=\s*({.+?});', webpage, |
398 | 'playlist', default='{}'), | |
399 | playlist_id, fatal=False) | |
400 | title = playlist.get('title') or self._search_regex( | |
401 | r'>Videos\s+in\s+(.+?)\s+[Pp]laylist<', webpage, 'title', fatal=False) | |
e66e1a00 S |
402 | |
403 | return self.playlist_result( | |
cd138d8b | 404 | entries, playlist_id, title, playlist.get('description')) |
40e146aa S |
405 | |
406 | ||
21b08463 | 407 | class PornHubUserIE(PornHubPlaylistBaseIE): |
9634de17 | 408 | _VALID_URL = r'(?P<url>https?://(?:[^/]+\.)?pornhub\.(?:com|net)/(?:(?:user|channel)s|model|pornstar)/(?P<id>[^/?#&]+))(?:[?#&]|/(?!videos)|$)' |
40e146aa | 409 | _TESTS = [{ |
21b08463 S |
410 | 'url': 'https://www.pornhub.com/model/zoe_ph', |
411 | 'playlist_mincount': 118, | |
412 | }, { | |
413 | 'url': 'https://www.pornhub.com/pornstar/liz-vicious', | |
40e146aa | 414 | 'info_dict': { |
21b08463 | 415 | 'id': 'liz-vicious', |
40e146aa | 416 | }, |
21b08463 S |
417 | 'playlist_mincount': 118, |
418 | }, { | |
419 | 'url': 'https://www.pornhub.com/users/russianveet69', | |
9634de17 | 420 | 'only_matching': True, |
21b08463 S |
421 | }, { |
422 | 'url': 'https://www.pornhub.com/channels/povd', | |
9634de17 S |
423 | 'only_matching': True, |
424 | }, { | |
425 | 'url': 'https://www.pornhub.com/model/zoe_ph?abc=1', | |
426 | 'only_matching': True, | |
21b08463 S |
427 | }] |
428 | ||
21b08463 S |
429 | def _real_extract(self, url): |
430 | mobj = re.match(self._VALID_URL, url) | |
431 | user_id = mobj.group('id') | |
432 | return self.url_result( | |
9634de17 | 433 | '%s/videos' % mobj.group('url'), ie=PornHubPagedVideoListIE.ie_key(), |
21b08463 S |
434 | video_id=user_id) |
435 | ||
436 | ||
437 | class PornHubPagedPlaylistBaseIE(PornHubPlaylistBaseIE): | |
4bf568d3 S |
438 | @staticmethod |
439 | def _has_more(webpage): | |
440 | return re.search( | |
441 | r'''(?x) | |
442 | <li[^>]+\bclass=["\']page_next| | |
443 | <link[^>]+\brel=["\']next| | |
444 | <button[^>]+\bid=["\']moreDataBtn | |
445 | ''', webpage) is not None | |
446 | ||
21b08463 S |
447 | def _real_extract(self, url): |
448 | mobj = re.match(self._VALID_URL, url) | |
449 | host = mobj.group('host') | |
9634de17 | 450 | item_id = mobj.group('id') |
21b08463 | 451 | |
1f7a563a S |
452 | page = int_or_none(self._search_regex( |
453 | r'\bpage=(\d+)', url, 'page', default=None)) | |
454 | ||
21b08463 | 455 | entries = [] |
1f7a563a | 456 | for page_num in (page, ) if page is not None else itertools.count(1): |
21b08463 S |
457 | try: |
458 | webpage = self._download_webpage( | |
4bf568d3 | 459 | url, item_id, 'Downloading page %d' % page_num, |
21b08463 S |
460 | query={'page': page_num}) |
461 | except ExtractorError as e: | |
462 | if isinstance(e.cause, compat_HTTPError) and e.cause.code == 404: | |
463 | break | |
464 | raise | |
465 | page_entries = self._extract_entries(webpage, host) | |
466 | if not page_entries: | |
467 | break | |
468 | entries.extend(page_entries) | |
469 | if not self._has_more(webpage): | |
470 | break | |
471 | ||
9634de17 | 472 | return self.playlist_result(orderedSet(entries), item_id) |
21b08463 S |
473 | |
474 | ||
9634de17 S |
475 | class PornHubPagedVideoListIE(PornHubPagedPlaylistBaseIE): |
476 | _VALID_URL = r'https?://(?:[^/]+\.)?(?P<host>pornhub\.(?:com|net))/(?P<id>(?:[^/]+/)*[^/?#&]+)' | |
21b08463 | 477 | _TESTS = [{ |
1f7a563a | 478 | 'url': 'https://www.pornhub.com/model/zoe_ph/videos', |
21b08463 | 479 | 'only_matching': True, |
34541395 S |
480 | }, { |
481 | 'url': 'http://www.pornhub.com/users/rushandlia/videos', | |
482 | 'only_matching': True, | |
21b08463 S |
483 | }, { |
484 | 'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos', | |
485 | 'info_dict': { | |
9634de17 | 486 | 'id': 'pornstar/jenny-blighe/videos', |
21b08463 S |
487 | }, |
488 | 'playlist_mincount': 149, | |
1f7a563a S |
489 | }, { |
490 | 'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos?page=3', | |
491 | 'info_dict': { | |
9634de17 | 492 | 'id': 'pornstar/jenny-blighe/videos', |
1f7a563a S |
493 | }, |
494 | 'playlist_mincount': 40, | |
f66df20c PV |
495 | }, { |
496 | # default sorting as Top Rated Videos | |
497 | 'url': 'https://www.pornhub.com/channels/povd/videos', | |
498 | 'info_dict': { | |
9634de17 | 499 | 'id': 'channels/povd/videos', |
f66df20c PV |
500 | }, |
501 | 'playlist_mincount': 293, | |
502 | }, { | |
503 | # Top Rated Videos | |
504 | 'url': 'https://www.pornhub.com/channels/povd/videos?o=ra', | |
505 | 'only_matching': True, | |
506 | }, { | |
507 | # Most Recent Videos | |
508 | 'url': 'https://www.pornhub.com/channels/povd/videos?o=da', | |
509 | 'only_matching': True, | |
510 | }, { | |
511 | # Most Viewed Videos | |
512 | 'url': 'https://www.pornhub.com/channels/povd/videos?o=vi', | |
513 | 'only_matching': True, | |
92ded33a S |
514 | }, { |
515 | 'url': 'http://www.pornhub.com/users/zoe_ph/videos/public', | |
516 | 'only_matching': True, | |
21b08463 S |
517 | }, { |
518 | # Most Viewed Videos | |
519 | 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=mv', | |
520 | 'only_matching': True, | |
521 | }, { | |
522 | # Top Rated Videos | |
523 | 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=tr', | |
524 | 'only_matching': True, | |
525 | }, { | |
526 | # Longest Videos | |
527 | 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=lg', | |
528 | 'only_matching': True, | |
529 | }, { | |
530 | # Newest Videos | |
531 | 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=cm', | |
532 | 'only_matching': True, | |
21b08463 S |
533 | }, { |
534 | 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos/paid', | |
535 | 'only_matching': True, | |
536 | }, { | |
537 | 'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos/fanonly', | |
538 | 'only_matching': True, | |
9634de17 S |
539 | }, { |
540 | 'url': 'https://www.pornhub.com/video', | |
541 | 'only_matching': True, | |
542 | }, { | |
543 | 'url': 'https://www.pornhub.com/video?page=3', | |
544 | 'only_matching': True, | |
545 | }, { | |
546 | 'url': 'https://www.pornhub.com/video/search?search=123', | |
547 | 'only_matching': True, | |
548 | }, { | |
549 | 'url': 'https://www.pornhub.com/categories/teen', | |
550 | 'only_matching': True, | |
551 | }, { | |
552 | 'url': 'https://www.pornhub.com/categories/teen?page=3', | |
553 | 'only_matching': True, | |
554 | }, { | |
555 | 'url': 'https://www.pornhub.com/hd', | |
556 | 'only_matching': True, | |
557 | }, { | |
558 | 'url': 'https://www.pornhub.com/hd?page=3', | |
559 | 'only_matching': True, | |
560 | }, { | |
561 | 'url': 'https://www.pornhub.com/described-video', | |
562 | 'only_matching': True, | |
563 | }, { | |
564 | 'url': 'https://www.pornhub.com/described-video?page=2', | |
565 | 'only_matching': True, | |
566 | }, { | |
567 | 'url': 'https://www.pornhub.com/video/incategories/60fps-1/hd-porn', | |
568 | 'only_matching': True, | |
569 | }, { | |
570 | 'url': 'https://www.pornhub.com/playlist/44121572', | |
571 | 'info_dict': { | |
572 | 'id': 'playlist/44121572', | |
573 | }, | |
574 | 'playlist_mincount': 132, | |
575 | }, { | |
576 | 'url': 'https://www.pornhub.com/playlist/4667351', | |
577 | 'only_matching': True, | |
578 | }, { | |
579 | 'url': 'https://de.pornhub.com/playlist/4667351', | |
580 | 'only_matching': True, | |
40e146aa S |
581 | }] |
582 | ||
21b08463 S |
583 | @classmethod |
584 | def suitable(cls, url): | |
585 | return (False | |
9634de17 S |
586 | if PornHubIE.suitable(url) or PornHubUserIE.suitable(url) or PornHubUserVideosUploadIE.suitable(url) |
587 | else super(PornHubPagedVideoListIE, cls).suitable(url)) | |
21b08463 | 588 | |
34541395 | 589 | |
21b08463 S |
590 | class PornHubUserVideosUploadIE(PornHubPagedPlaylistBaseIE): |
591 | _VALID_URL = r'(?P<url>https?://(?:[^/]+\.)?(?P<host>pornhub\.(?:com|net))/(?:(?:user|channel)s|model|pornstar)/(?P<id>[^/]+)/videos/upload)' | |
592 | _TESTS = [{ | |
593 | 'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos/upload', | |
594 | 'info_dict': { | |
595 | 'id': 'jenny-blighe', | |
596 | }, | |
597 | 'playlist_mincount': 129, | |
598 | }, { | |
599 | 'url': 'https://www.pornhub.com/model/zoe_ph/videos/upload', | |
600 | 'only_matching': True, | |
601 | }] |