diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 5d55121f070..12d93c2facc 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -1627,6 +1627,7 @@ XVideosPlaylistIE, XVideosRelatedIE, XVideosSearchIE, + XVideosSearchKeyIE, ) from .xxxymovies import XXXYMoviesIE from .yahoo import ( diff --git a/youtube_dl/extractor/xvideos.py b/youtube_dl/extractor/xvideos.py index 675d4efec79..662fe43c045 100644 --- a/youtube_dl/extractor/xvideos.py +++ b/youtube_dl/extractor/xvideos.py @@ -996,4 +996,39 @@ def _get_title(self, page, playlist_id, **kwargs): sub = join_nonempty(*sub, delim=',') if sub: title = '%s (%s)' % (title, sub) - return title \ No newline at end of file + 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': 'xhsearch50: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 \ No newline at end of file