From 71b64796da4fb4f685ef82dedb2afa992f33be00 Mon Sep 17 00:00:00 2001 From: sigma67 Date: Mon, 29 Nov 2021 11:52:47 +0100 Subject: [PATCH] fix get_watch_playlist results if only videoid is provided --- ytmusicapi/mixins/watch.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ytmusicapi/mixins/watch.py b/ytmusicapi/mixins/watch.py index 95e4988..d5e3dd2 100644 --- a/ytmusicapi/mixins/watch.py +++ b/ytmusicapi/mixins/watch.py @@ -48,19 +48,21 @@ class WatchMixin: """ body = {'enablePersistentPlaylistPanel': True, 'isAudioOnly': True} + if not videoId and not playlistId: + raise Exception("You must provide either a video id, a playlist id, or both") if videoId: body['videoId'] = videoId + if not playlistId: + playlistId = "RDAMVM" + videoId if not params: body['watchEndpointMusicSupportedConfigs'] = { 'watchEndpointMusicConfig': { 'hasPersistentPlaylistPanel': True, - 'musicVideoType': "MUSIC_VIDEO_TYPE_OMV", + 'musicVideoType': "MUSIC_VIDEO_TYPE_ATV", } } - is_playlist = False - if playlistId: - body['playlistId'] = validate_playlist_id(playlistId) - is_playlist = body['playlistId'].startswith('PL') + body['playlistId'] = validate_playlist_id(playlistId) + is_playlist = body['playlistId'].startswith('PL') if params: body['params'] = params endpoint = 'next'