Fix for KeyError when searching community_playlists or featured_playlists. Closes #420 (#421)

* Fix for issue #420 KeyError when searching community_playlists or featured_playlists with scope library

* From PR feedback - better exception message for search guard clause.

* Fixed lint
This commit is contained in:
nick42d 2023-08-05 18:23:23 +08:00 • committed by GitHub
commit 3bf7b49eab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View file

@ -137,6 +137,18 @@ class TestYTMusic(unittest.TestCase):
self.assertGreaterEqual(len(results), 1)
results = self.yt_auth.search("garrix", filter="playlists", scope="library")
self.assertGreaterEqual(len(results), 1)
self.assertRaises(Exception,
self.yt_auth.search,
"beatles",
filter="community_playlists",
scope="library",
limit=40)
self.assertRaises(Exception,
self.yt_auth.search,
"beatles",
filter="featured_playlists",
scope="library",
limit=40)
def test_get_artist(self):
results = self.yt.get_artist("MPLAUCmMUZbaYdNH0bEd1PAlAqsA")
@ -164,7 +176,7 @@ class TestYTMusic(unittest.TestCase):
def test_get_artist_singles(self):
artist = self.yt.get_artist("UCAeLFBCQS7FvI8PvBrWvSBg")
results = self.yt.get_artist_albums(artist["singles"]["browseId"],
artist["singles"]["params"])
artist["singles"]["params"])
self.assertGreater(len(results), 0)
def test_get_user(self):