search: raise Exception when filter is set for uploads search (closes #285)
This commit is contained in:
parent
b3e233e75c
commit
fbb26dde94
2 changed files with 13 additions and 0 deletions
|
|
@ -69,6 +69,12 @@ class TestYTMusic(unittest.TestCase):
|
||||||
self.assertGreater(len(results), 5)
|
self.assertGreater(len(results), 5)
|
||||||
|
|
||||||
def test_search_uploads(self):
|
def test_search_uploads(self):
|
||||||
|
self.assertRaises(Exception,
|
||||||
|
self.yt.search,
|
||||||
|
'audiomachine',
|
||||||
|
filter="songs",
|
||||||
|
scope='uploads',
|
||||||
|
limit=40)
|
||||||
results = self.yt_auth.search('audiomachine', scope='uploads', limit=40)
|
results = self.yt_auth.search('audiomachine', scope='uploads', limit=40)
|
||||||
self.assertGreater(len(results), 20)
|
self.assertGreater(len(results), 20)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ class SearchMixin:
|
||||||
:param filter: Filter for item types. Allowed values: ``songs``, ``videos``, ``albums``, ``artists``, ``playlists``, ``community_playlists``, ``featured_playlists``, ``uploads``.
|
:param filter: Filter for item types. Allowed values: ``songs``, ``videos``, ``albums``, ``artists``, ``playlists``, ``community_playlists``, ``featured_playlists``, ``uploads``.
|
||||||
Default: Default search, including all types of items.
|
Default: Default search, including all types of items.
|
||||||
:param scope: Search scope. Allowed values: ``library``, ``uploads``.
|
:param scope: Search scope. Allowed values: ``library``, ``uploads``.
|
||||||
|
For uploads, no filter can be set! An exception will be thrown if you attempt to do so.
|
||||||
Default: Search the public YouTube Music catalogue.
|
Default: Search the public YouTube Music catalogue.
|
||||||
:param limit: Number of search results to return
|
:param limit: Number of search results to return
|
||||||
Default: 20
|
Default: 20
|
||||||
|
|
@ -137,6 +138,12 @@ class SearchMixin:
|
||||||
"Invalid scope provided. Please use one of the following scopes or leave out the parameter: "
|
"Invalid scope provided. Please use one of the following scopes or leave out the parameter: "
|
||||||
+ ', '.join(scopes))
|
+ ', '.join(scopes))
|
||||||
|
|
||||||
|
if scope == scopes[1] and filter:
|
||||||
|
raise Exception(
|
||||||
|
"No filter can be set when searching uploads. Please unset the filter parameter when scope is set to "
|
||||||
|
"uploads. "
|
||||||
|
)
|
||||||
|
|
||||||
params = get_search_params(filter, scope, ignore_spelling)
|
params = get_search_params(filter, scope, ignore_spelling)
|
||||||
if params:
|
if params:
|
||||||
body['params'] = params
|
body['params'] = params
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue