mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-06-28 01:18:30 +00:00
Merge a25016a580
into 73bf102116
This commit is contained in:
commit
2717044173
@ -423,7 +423,7 @@ def _real_extract(self, url):
|
|||||||
|
|
||||||
|
|
||||||
class XHamsterUserIE(InfoExtractor):
|
class XHamsterUserIE(InfoExtractor):
|
||||||
_VALID_URL = rf'https?://(?:[^/?#]+\.)?{XHamsterIE._DOMAINS}/(?:(?P<user>users)|creators)/(?P<id>[^/?#&]+)'
|
_VALID_URL = rf'https?://(?:[^/?#]+\.)?{XHamsterIE._DOMAINS}/(?P<collection>users|creators|channels)/(?P<id>[^/?#&]+)(?P<favorites>/favorites/videos)?'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
# Paginated user profile
|
# Paginated user profile
|
||||||
'url': 'https://xhamster.com/users/netvideogirls/videos',
|
'url': 'https://xhamster.com/users/netvideogirls/videos',
|
||||||
@ -437,13 +437,25 @@ class XHamsterUserIE(InfoExtractor):
|
|||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'firatkaan',
|
'id': 'firatkaan',
|
||||||
},
|
},
|
||||||
'playlist_mincount': 1,
|
'playlist_mincount': 0,
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://xhamster.com/creators/squirt-orgasm-69',
|
'url': 'https://xhamster.com/creators/squirt-orgasm-69',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'squirt-orgasm-69',
|
'id': 'squirt-orgasm-69',
|
||||||
},
|
},
|
||||||
'playlist_mincount': 150,
|
'playlist_mincount': 150,
|
||||||
|
}, {
|
||||||
|
'url': 'https://xhamster.com/channels/patreon/',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'patreon',
|
||||||
|
},
|
||||||
|
'playlist_mincount': 500,
|
||||||
|
}, {
|
||||||
|
'url': 'https://xhamster.com/users/cubafidel/favorites/videos',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'cubafidel',
|
||||||
|
},
|
||||||
|
'playlist_mincount': 220,
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://xhday.com/users/mobhunter',
|
'url': 'https://xhday.com/users/mobhunter',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
@ -452,9 +464,15 @@ class XHamsterUserIE(InfoExtractor):
|
|||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _entries(self, user_id, is_user):
|
def _entries(self, user_id, collection_type):
|
||||||
prefix, suffix = ('users', 'videos') if is_user else ('creators', 'exclusive')
|
collection_prefixes = {
|
||||||
next_page_url = f'https://xhamster.com/{prefix}/{user_id}/{suffix}/1'
|
'users': ('users', 'videos/'),
|
||||||
|
'creators': ('creators', 'exclusive/'),
|
||||||
|
'channels': ('channels', ''),
|
||||||
|
'favorites': ('users', 'favorites/videos/'),
|
||||||
|
}
|
||||||
|
prefix, suffix = collection_prefixes[collection_type]
|
||||||
|
next_page_url = f'https://xhamster.com/{prefix}/{user_id}/{suffix}1'
|
||||||
for pagenum in itertools.count(1):
|
for pagenum in itertools.count(1):
|
||||||
page = self._download_webpage(
|
page = self._download_webpage(
|
||||||
next_page_url, user_id, f'Downloading page {pagenum}')
|
next_page_url, user_id, f'Downloading page {pagenum}')
|
||||||
@ -468,7 +486,7 @@ def _entries(self, user_id, is_user):
|
|||||||
video_id = XHamsterIE._match_id(video_url)
|
video_id = XHamsterIE._match_id(video_url)
|
||||||
yield self.url_result(
|
yield self.url_result(
|
||||||
video_url, ie=XHamsterIE.ie_key(), video_id=video_id)
|
video_url, ie=XHamsterIE.ie_key(), video_id=video_id)
|
||||||
mobj = re.search(r'<a[^>]+data-page=["\']next[^>]+>', page)
|
mobj = re.search(r'<a[^>]+(?:data-page=["\']next|rel=["\']next)[^>]+>', page)
|
||||||
if not mobj:
|
if not mobj:
|
||||||
break
|
break
|
||||||
next_page = extract_attributes(mobj.group(0))
|
next_page = extract_attributes(mobj.group(0))
|
||||||
@ -477,5 +495,6 @@ def _entries(self, user_id, is_user):
|
|||||||
break
|
break
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
user, user_id = self._match_valid_url(url).group('user', 'id')
|
collection_type, user_id, favorites = self._match_valid_url(url).group('collection', 'id', 'favorites')
|
||||||
return self.playlist_result(self._entries(user_id, bool(user)), user_id)
|
collection_type = 'favorites' if bool(favorites) else collection_type
|
||||||
|
return self.playlist_result(self._entries(user_id, collection_type), user_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user