Add videoId param for shuffling playlists (determines first video in shuffled playlist)
This commit is contained in:
parent
23f278cd85
commit
cc69b56c20
2 changed files with 11 additions and 8 deletions
|
|
@ -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)
|
||||
|
||||
###############
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue