Add videoId param for shuffling playlists (determines first video in shuffled playlist)

This commit is contained in:
sigma67 2021-02-17 15:44:26 +01:00
commit cc69b56c20
No known key found for this signature in database
GPG key ID: 1545A01D4474BAF0
2 changed files with 11 additions and 8 deletions

View file

@ -121,8 +121,8 @@ class TestYTMusic(unittest.TestCase):
self.assertEqual(len(playlist['tracks']), 12)
def test_get_watch_playlist_shuffle_playlist(self):
playlist = youtube.get_watch_playlist_shuffle(
playlistId="PL528pVfw3ao0x8jlW3kwdIx1FEMMeeghb", limit=99)
playlist = youtube_auth.get_watch_playlist_shuffle(
videoId="u6XiiXJD0jg", playlistId="PL528pVfw3ao2VzfY6zE1TOZm1cBSdk7Q0", limit=99)
self.assertGreaterEqual(len(playlist['tracks']), 80)
###############

View file

@ -50,12 +50,13 @@ class WatchMixin:
body = {'enablePersistentPlaylistPanel': True, 'isAudioOnly': True}
if videoId:
body['videoId'] = videoId
body['watchEndpointMusicSupportedConfigs'] = {
'watchEndpointMusicConfig': {
'hasPersistentPlaylistPanel': True,
'musicVideoType': "MUSIC_VIDEO_TYPE_OMV",
if not params:
body['watchEndpointMusicSupportedConfigs'] = {
'watchEndpointMusicConfig': {
'hasPersistentPlaylistPanel': True,
'musicVideoType': "MUSIC_VIDEO_TYPE_OMV",
}
}
}
is_playlist = False
if playlistId:
body['playlistId'] = playlistId
@ -89,13 +90,15 @@ class WatchMixin:
return {'tracks': tracks, 'lyrics': lyrics_browse_id}
def get_watch_playlist_shuffle(self,
videoId: str = None,
playlistId: str = None,
limit=50) -> Dict[List[Dict], str]:
"""
Shuffle any playlist
:param videoId: Optional video id of the first video in the shuffled playlist
:param playlistId: Playlist id
:param limit: The number of watch playlist items to return
:return: A list of watch playlist items (see :py:func:`get_watch_playlist`)
"""
return self.get_watch_playlist(playlistId=playlistId, limit=limit, params='wAEB8gECGAE%3D')
return self.get_watch_playlist(videoId=videoId, playlistId=playlistId, limit=limit, params='wAEB8gECKAE%3D')