get_playlist: support None limit (#275)
This commit is contained in:
parent
c85fd8c810
commit
ec771fc976
2 changed files with 7 additions and 2 deletions
|
|
@ -329,9 +329,12 @@ class TestYTMusic(unittest.TestCase):
|
||||||
###############
|
###############
|
||||||
|
|
||||||
def test_get_foreign_playlist(self):
|
def test_get_foreign_playlist(self):
|
||||||
playlist = self.yt.get_playlist(sample_playlist, 300)
|
playlist = self.yt.get_playlist(sample_playlist, limit=300)
|
||||||
self.assertGreater(len(playlist['tracks']), 200)
|
self.assertGreater(len(playlist['tracks']), 200)
|
||||||
|
|
||||||
|
playlist = self.yt.get_playlist("RDCLAK5uy_kpxnNxJpPZjLKbL9WgvrPuErWkUxMP6x4", limit=None)
|
||||||
|
self.assertGreater(len(playlist['tracks']), 100)
|
||||||
|
|
||||||
def test_get_owned_playlist(self):
|
def test_get_owned_playlist(self):
|
||||||
playlist = self.yt_brand.get_playlist(config['playlists']['own'])
|
playlist = self.yt_brand.get_playlist(config['playlists']['own'])
|
||||||
self.assertLess(len(playlist['tracks']), 100)
|
self.assertLess(len(playlist['tracks']), 100)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class PlaylistsMixin:
|
||||||
Returns a list of playlist items
|
Returns a list of playlist items
|
||||||
|
|
||||||
:param playlistId: Playlist id
|
:param playlistId: Playlist id
|
||||||
:param limit: How many songs to return. Default: 100
|
:param limit: How many songs to return. `None` retrieves them all. Default: 100
|
||||||
:return: Dictionary with information about the playlist.
|
:return: Dictionary with information about the playlist.
|
||||||
The key ``tracks`` contains a List of playlistItem dictionaries
|
The key ``tracks`` contains a List of playlistItem dictionaries
|
||||||
|
|
||||||
|
|
@ -106,6 +106,8 @@ class PlaylistsMixin:
|
||||||
playlist['tracks'] = []
|
playlist['tracks'] = []
|
||||||
if song_count > 0:
|
if song_count > 0:
|
||||||
playlist['tracks'].extend(parse_playlist_items(results['contents']))
|
playlist['tracks'].extend(parse_playlist_items(results['contents']))
|
||||||
|
if limit is None:
|
||||||
|
limit = song_count
|
||||||
songs_to_get = min(limit, song_count)
|
songs_to_get = min(limit, song_count)
|
||||||
|
|
||||||
if 'continuations' in results:
|
if 'continuations' in results:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue