1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-18 00:05:46 +00:00

[XVideos] Add XVideosSearchKeyIE to implement a search key: xvsearchnnn:needle

This commit is contained in:
dirkf 2023-10-16 04:16:01 +01:00
parent 596a6203f7
commit cc1657b753
2 changed files with 36 additions and 0 deletions

View file

@ -1626,6 +1626,7 @@ from .xvideos import (
XVideosPlaylistIE,
XVideosRelatedIE,
XVideosSearchIE,
XVideosSearchKeyIE,
)
from .xxxymovies import XXXYMoviesIE
from .yahoo import (

View file

@ -1008,3 +1008,38 @@ class XVideosSearchIE(XVideosPlaylistBaseIE):
if sub:
title = '%s (%s)' % (title, sub)
return title
class XVideosSearchKeyIE(SearchInfoExtractor, XVideosSearchIE):
_SEARCH_KEY = 'xvsearch'
_MAX_RESULTS = float('inf')
_TESTS = [{
'note': 'full search',
'url': 'xvsearchall:lithuania',
'info_dict': {
'id': 'lithuania',
'title': 'lithuania (all)',
},
'playlist_mincount': 75,
}, {
'note': 'Subset of paginated result',
'url': 'xvsearch50:lithuania',
'info_dict': {
'id': 'lithuania',
'title': 'lithuania (first 50)',
},
'playlist_count': 50,
}]
def _get_n_results(self, query, n):
"""Get a specified number of results for a query"""
result = XVideosSearchIE._real_extract(
self, 'https://www.xvideos.com/?k=' + query.replace(' ', '+'))
if not isinf(n):
result['entries'] = itertools.islice(result['entries'], n)
if result.get('title') is not None:
result['title'] = result['title'].replace('(all)', '(first %d)' % n)
return result