Skip to content

Commit

Permalink
[youtube:search] Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pukkandan authored and dirkf committed Feb 4, 2022
1 parent 7a497f1 commit 0c0876f
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions youtube_dl/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -3206,7 +3206,14 @@ class YoutubeSearchIE(SearchInfoExtractor, YoutubeBaseInfoExtractor):
_SEARCH_KEY = 'ytsearch'
_SEARCH_PARAMS = 'EgIQAQ%3D%3D' # Videos only
_MAX_RESULTS = float('inf')
_TESTS = []
_TESTS = [{
'url': 'ytsearch10:youtube-dl test video',
'playlist_count': 10,
'info_dict': {
'id': 'youtube-dl test video',
'title': 'youtube-dl test video',
}
}]

def _get_n_results(self, query, n):
"""Get a specified number of results for a query"""
Expand All @@ -3219,7 +3226,14 @@ class YoutubeSearchDateIE(YoutubeSearchIE):
_SEARCH_KEY = 'ytsearchdate'
IE_DESC = 'YouTube.com searches, newest videos first'
_SEARCH_PARAMS = 'CAISAhAB' # Videos only, sorted by date
_TESTS = []
_TESTS = [{
'url': 'ytsearchdate10:youtube-dl test video',
'playlist_count': 10,
'info_dict': {
'id': 'youtube-dl test video',
'title': 'youtube-dl test video',
}
}]


class YoutubeSearchURLIE(YoutubeBaseInfoExtractor):
Expand All @@ -3232,7 +3246,8 @@ class YoutubeSearchURLIE(YoutubeBaseInfoExtractor):
'info_dict': {
'id': 'youtube-dl test video',
'title': 'youtube-dl test video',
}
},
'params': {'playlistend': 5}
}, {
'url': 'https://www.youtube.com/results?q=test&sp=EgQIBBgB',
'only_matching': True,
Expand Down

0 comments on commit 0c0876f

Please sign in to comment.