Skip to content

Commit

Permalink
[XVideos] Add XVideosSearchKeyIE to implement a search key: xvsearchn…
Browse files Browse the repository at this point in the history
…nn:needle
  • Loading branch information
dirkf committed Oct 22, 2023
1 parent 596a620 commit 629d407
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions youtube_dl/extractor/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,7 @@
XVideosPlaylistIE,
XVideosRelatedIE,
XVideosSearchIE,
XVideosSearchKeyIE,
)
from .xxxymovies import XXXYMoviesIE
from .yahoo import (
Expand Down
35 changes: 35 additions & 0 deletions youtube_dl/extractor/xvideos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,3 +1008,38 @@ def _get_title(self, page, playlist_id, **kwargs):
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': '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

0 comments on commit 629d407

Please sign in to comment.