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 18, 2023
1 parent 0fbf01e commit d4ba4d2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions youtube_dl/extractor/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,7 @@
XVideosPlaylistIE,
XVideosRelatedIE,
XVideosSearchIE,
XVideosSearchKeyIE,
)
from .xxxymovies import XXXYMoviesIE
from .yahoo import (
Expand Down
37 changes: 36 additions & 1 deletion youtube_dl/extractor/xvideos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 d4ba4d2

Please sign in to comment.