mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-03-27 18:27:27 +09:00
[XVideos] Add XVideosSearchKeyIE to implement a search key: xvsearchnnn:needle
This commit is contained in:
parent
596a6203f7
commit
cc1657b753
@ -1626,6 +1626,7 @@ from .xvideos import (
|
|||||||
XVideosPlaylistIE,
|
XVideosPlaylistIE,
|
||||||
XVideosRelatedIE,
|
XVideosRelatedIE,
|
||||||
XVideosSearchIE,
|
XVideosSearchIE,
|
||||||
|
XVideosSearchKeyIE,
|
||||||
)
|
)
|
||||||
from .xxxymovies import XXXYMoviesIE
|
from .xxxymovies import XXXYMoviesIE
|
||||||
from .yahoo import (
|
from .yahoo import (
|
||||||
|
@ -1008,3 +1008,38 @@ class XVideosSearchIE(XVideosPlaylistBaseIE):
|
|||||||
if sub:
|
if sub:
|
||||||
title = '%s (%s)' % (title, 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': '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
|
||||||
|
Loading…
Reference in New Issue
Block a user