diff --git a/tests/test.py b/tests/test.py index df60f54..50eae4e 100644 --- a/tests/test.py +++ b/tests/test.py @@ -69,6 +69,12 @@ class TestYTMusic(unittest.TestCase): self.assertGreater(len(results), 5) 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) self.assertGreater(len(results), 20) diff --git a/ytmusicapi/mixins/search.py b/ytmusicapi/mixins/search.py index 9164c1d..281e61d 100644 --- a/ytmusicapi/mixins/search.py +++ b/ytmusicapi/mixins/search.py @@ -19,6 +19,7 @@ class SearchMixin: :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. :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. :param limit: Number of search results to return Default: 20 @@ -137,6 +138,12 @@ class SearchMixin: "Invalid scope provided. Please use one of the following scopes or leave out the parameter: " + ', '.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) if params: body['params'] = params