mirror of
https://github.com/sigma67/ytmusicapi.git
synced 2026-04-25 23:36:00 +03:00
[GH-ISSUE #397] HTTP 400 error when using add_playlist_items #309
Labels
No labels
a/b
bug
documentation
enhancement
good first issue
help wanted
invalid
pull-request
question
wontfix
yt-error
yt-update
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ytmusicapi#309
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @CannedBreb89 on GitHub (Jun 10, 2023).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/397
Using add_playlist_items causes a "Bad Request" error. I've tried different IDs, playlists, and songs, using the IDs instead of variables, I tried copying the code from the tests, but nothing's worked. Any help would be appreciated, thank you.
Code:
`from ytmusicapi import YTMusic
yt = YTMusic("oauth.json")
songSearch = str("Back in Black")
searchResults = yt.search(query=songSearch, filter='songs', scope=None, limit=1, ignore_spelling=False)
playlists = yt.get_library_playlists(limit=5)
#Song search and playlist info (respectively)
songData = searchResults[0]
listData = playlists[0]
#Song and playlist IDs (respectively)
songID = songData['videoId']
listID = listData['playlistId']
print("Target Playlist ID:", listID)
print("Song title:", songData['title'], "\nAlbum title:", songData['album']['name'], "\nSong ID:", songData['videoId'])
yt.add_playlist_items(playlistId=listID, videoIds=songID, source_playlist=listID, duplicates=False)`
Output:
Target Playlist ID: PLqfZ3LIWPHtZECZe00K9rAfOlba8XKm7G Song title: Back In Black Album title: Back In Black Song ID: 9vWNauaZAgg Traceback (most recent call last): File "c:\Users\[user]\YTMusicBot\ytaudio.py", line 20, in <module> yt.add_playlist_items(playlistId=listID, videoIds=songID, source_playlist=listID, duplicates=False) File "c:\Users\[user]\YTMusicBot\ytmusicapi\mixins\playlists.py", line 328, in add_playlist_items response = self._send_request(endpoint, body) File "c:\Users\[user]\YTMusicBot\ytmusicapi\ytmusic.py", line 132, in _send_request raise Exception(message + error) Exception: Server returned HTTP 400: Bad Request. Request contains an invalid argument.@sigma67 commented on GitHub (Jun 13, 2023):
Tests are passing, so there's something wrong with your input. Please debug. This is not a forum for questions.