mirror of
https://gitlab.com/dstftw/youtube-dl.git
synced 2020-11-16 09:42:26 +00:00
[pornhub] Add support for downloading single pages and search pages (closes #15570)
This commit is contained in:
parent
21b08463a7
commit
1f7a563ab0
|
@ -409,14 +409,14 @@ class PornHubUserIE(PornHubPlaylistBaseIE):
|
||||||
@classmethod
|
@classmethod
|
||||||
def suitable(cls, url):
|
def suitable(cls, url):
|
||||||
return (False
|
return (False
|
||||||
if PornHubUserVideosIE.suitable(url) or PornHubUserVideosUploadIE.suitable(url)
|
if PornHubPagedVideosIE.suitable(url) or PornHubUserVideosUploadIE.suitable(url)
|
||||||
else super(PornHubUserIE, cls).suitable(url))
|
else super(PornHubUserIE, cls).suitable(url))
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
user_id = mobj.group('id')
|
user_id = mobj.group('id')
|
||||||
return self.url_result(
|
return self.url_result(
|
||||||
'%s/videos' % mobj.group('url'), ie=PornHubUserVideosIE.ie_key(),
|
'%s/videos' % mobj.group('url'), ie=PornHubPagedVideosIE.ie_key(),
|
||||||
video_id=user_id)
|
video_id=user_id)
|
||||||
|
|
||||||
|
|
||||||
|
@ -426,10 +426,13 @@ class PornHubPagedPlaylistBaseIE(PornHubPlaylistBaseIE):
|
||||||
host = mobj.group('host')
|
host = mobj.group('host')
|
||||||
user_id = mobj.group('id')
|
user_id = mobj.group('id')
|
||||||
|
|
||||||
|
page = int_or_none(self._search_regex(
|
||||||
|
r'\bpage=(\d+)', url, 'page', default=None))
|
||||||
|
|
||||||
page_url = self._make_page_url(url)
|
page_url = self._make_page_url(url)
|
||||||
|
|
||||||
entries = []
|
entries = []
|
||||||
for page_num in itertools.count(1):
|
for page_num in (page, ) if page is not None else itertools.count(1):
|
||||||
try:
|
try:
|
||||||
webpage = self._download_webpage(
|
webpage = self._download_webpage(
|
||||||
page_url, user_id, 'Downloading page %d' % page_num,
|
page_url, user_id, 'Downloading page %d' % page_num,
|
||||||
|
@ -448,10 +451,17 @@ class PornHubPagedPlaylistBaseIE(PornHubPlaylistBaseIE):
|
||||||
return self.playlist_result(orderedSet(entries), user_id)
|
return self.playlist_result(orderedSet(entries), user_id)
|
||||||
|
|
||||||
|
|
||||||
class PornHubUserVideosIE(PornHubPagedPlaylistBaseIE):
|
class PornHubPagedVideosIE(PornHubPagedPlaylistBaseIE):
|
||||||
_VALID_URL = r'https?://(?:[^/]+\.)?(?P<host>pornhub\.(?:com|net))/(?:(?:user|channel)s|model|pornstar)/(?P<id>[^/]+)/videos'
|
_VALID_URL = r'''(?x)
|
||||||
|
https?://
|
||||||
|
(?:[^/]+\.)?(?P<host>pornhub\.(?:com|net))/
|
||||||
|
(?:
|
||||||
|
(?:(?:user|channel)s|model|pornstar)/(?P<id>[^/]+)/videos|
|
||||||
|
video/search
|
||||||
|
)
|
||||||
|
'''
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://www.pornhub.com/model/zoe_ph/videos/upload',
|
'url': 'https://www.pornhub.com/model/zoe_ph/videos',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://www.pornhub.com/users/rushandlia/videos',
|
'url': 'http://www.pornhub.com/users/rushandlia/videos',
|
||||||
|
@ -462,6 +472,12 @@ class PornHubUserVideosIE(PornHubPagedPlaylistBaseIE):
|
||||||
'id': 'jenny-blighe',
|
'id': 'jenny-blighe',
|
||||||
},
|
},
|
||||||
'playlist_mincount': 149,
|
'playlist_mincount': 149,
|
||||||
|
}, {
|
||||||
|
'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos?page=3',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'jenny-blighe',
|
||||||
|
},
|
||||||
|
'playlist_mincount': 40,
|
||||||
}, {
|
}, {
|
||||||
# default sorting as Top Rated Videos
|
# default sorting as Top Rated Videos
|
||||||
'url': 'https://www.pornhub.com/channels/povd/videos',
|
'url': 'https://www.pornhub.com/channels/povd/videos',
|
||||||
|
@ -484,12 +500,6 @@ class PornHubUserVideosIE(PornHubPagedPlaylistBaseIE):
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://www.pornhub.com/users/zoe_ph/videos/public',
|
'url': 'http://www.pornhub.com/users/zoe_ph/videos/public',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}, {
|
|
||||||
'url': 'https://www.pornhub.com/model/jayndrea/videos/upload',
|
|
||||||
'only_matching': True,
|
|
||||||
}, {
|
|
||||||
'url': 'https://www.pornhub.com/pornstar/jenny-blighe/videos/upload',
|
|
||||||
'only_matching': True,
|
|
||||||
}, {
|
}, {
|
||||||
# Most Viewed Videos
|
# Most Viewed Videos
|
||||||
'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=mv',
|
'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=mv',
|
||||||
|
@ -506,9 +516,6 @@ class PornHubUserVideosIE(PornHubPagedPlaylistBaseIE):
|
||||||
# Newest Videos
|
# Newest Videos
|
||||||
'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=cm',
|
'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos?o=cm',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}, {
|
|
||||||
'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos/upload',
|
|
||||||
'only_matching': True,
|
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos/paid',
|
'url': 'https://www.pornhub.com/pornstar/liz-vicious/videos/paid',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
|
@ -521,7 +528,7 @@ class PornHubUserVideosIE(PornHubPagedPlaylistBaseIE):
|
||||||
def suitable(cls, url):
|
def suitable(cls, url):
|
||||||
return (False
|
return (False
|
||||||
if PornHubUserVideosUploadIE.suitable(url)
|
if PornHubUserVideosUploadIE.suitable(url)
|
||||||
else super(PornHubUserVideosIE, cls).suitable(url))
|
else super(PornHubPagedVideosIE, cls).suitable(url))
|
||||||
|
|
||||||
def _make_page_url(self, url):
|
def _make_page_url(self, url):
|
||||||
return url
|
return url
|
||||||
|
|
Loading…
Reference in a new issue