rimonhanna / Spotify-To-Youtube

64 stars 9 forks source link

Exception: Server returned HTTP 400: Bad Request. #19

Open djlivooo opened 1 year ago

djlivooo commented 1 year ago

Hi, When I play one of my playlists I get this error on some songs.

First, it starts normally, plays a few songs correctly, and then it starts to get this error, and then it keeps playing songs normally and so on. What is the reason for this error?

Traceback (most recent call last): File "C:\Users\varga\Downloads\Spotify-To-Youtube-main\spotifyToYoutube.py", line 26, in add_to_playlist ytmusic.add_playlist_items(target_playlist, [search_results[0]['videoId']]) File "C:\Users\varga\AppData\Local\Programs\Python\Python311\Lib\site-packages\ytmusicapi\mixins\playlists.py", line 275, in add_playlist_items response = self._send_request(endpoint, body) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\varga\AppData\Local\Programs\Python\Python311\Lib\site-packages\ytmusicapi\ytmusic.py", line 142, in _send_request raise Exception(message + error) Exception: Server returned HTTP 400: Bad Request. This functionality is not available right now. Please try again later.

fire4rt commented 1 year ago

Getting the same. One thing to note, it starts happening around 290 songs. No songs are added after that, each songs gets the error. This looks like a response from google/youtube, so maybe the cookie expires? If I try to start it again afterwards with the same cookie I get a 401 Unauthorized.

fire4rt commented 1 year ago

Getting the same. One thing to note, it starts happening around 290 songs. No songs are added after that, each songs gets the error. This looks like a response from google/youtube, so maybe the cookie expires? If I try to start it again afterwards with the same cookie I get a 401 Unauthorized.

Small update, I am not sure it if has anything to do with the authentication. I updated ytmisucapi and changed your code do use the oauth authentication method, but still started getting 400 Bad request from ytmusic after the 293rd song. I can't see anything wrong with the code, though I don't understand coding that much and I am not sure if I changed things correctly...but to me it looks like the issue is coming from YouTube.

kgielis commented 1 year ago

I tried several methods resolving this issue (updating the cookie every 290 songs, creating new instances of SpotifyToYoutube). Only thing that seemed to work was splitting large playlists into several smaller playlists and then manually combining them after they were migrated. I can create a PR to fix this if you want @rimonhanna.

rimonhanna commented 11 months ago

@kgielis appreciatie the debugging, if you open a PR I would happily review it an merge it!