fix empty liked songs crash caused by #399
This commit is contained in:
parent
e26335e664
commit
94f1513822
2 changed files with 10 additions and 4 deletions
|
|
@ -388,20 +388,23 @@ class TestYTMusic(unittest.TestCase):
|
|||
# PLAYLISTS
|
||||
###############
|
||||
|
||||
def test_get_foreign_playlist(self):
|
||||
def test_get_playlist_foreign(self):
|
||||
self.assertRaises(Exception, self.yt.get_playlist, "PLABC")
|
||||
playlist = self.yt.get_playlist(sample_playlist, limit=300, suggestions_limit=7)
|
||||
self.assertGreater(len(playlist['duration']), 5)
|
||||
self.assertGreater(len(playlist["tracks"]), 200)
|
||||
self.assertNotIn("suggestions", playlist)
|
||||
|
||||
self.yt.get_playlist("RDATgXd-")
|
||||
self.assertGreaterEqual(len(playlist["tracks"]), 100)
|
||||
|
||||
playlist = self.yt_oauth.get_playlist("PLj4BSJLnVpNyIjbCWXWNAmybc97FXLlTk",
|
||||
limit=None,
|
||||
related=True)
|
||||
self.assertGreater(len(playlist["tracks"]), 200)
|
||||
self.assertEqual(len(playlist["related"]), 0)
|
||||
|
||||
def test_get_owned_playlist(self):
|
||||
def test_get_playlist_owned(self):
|
||||
playlist = self.yt_brand.get_playlist(config["playlists"]["own"],
|
||||
related=True,
|
||||
suggestions_limit=21)
|
||||
|
|
|
|||
|
|
@ -140,8 +140,11 @@ class PlaylistsMixin:
|
|||
playlist['views'] = None if not has_views else to_int(second_subtitle_runs[0]['text'])
|
||||
has_duration = (len(second_subtitle_runs) > 1) * 2
|
||||
playlist['duration'] = None if not has_duration else second_subtitle_runs[has_views + has_duration]['text']
|
||||
|
||||
song_count = len(results['contents'])
|
||||
song_count = second_subtitle_runs[has_views + 0]['text'].split(" ")
|
||||
song_count = to_int(song_count[0]) if len(song_count) > 1 else 0
|
||||
else:
|
||||
song_count = len(results['contents'])
|
||||
|
||||
playlist['trackCount'] = song_count
|
||||
|
||||
request_func = lambda additionalParams: self._send_request(endpoint, body, additionalParams)
|
||||
|
|
|
|||
Loading…
Reference in a new issue