Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
djlivooo opened this issue Nov 11, 2023 · 8 comments
Open

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

djlivooo opened this issue Nov 11, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@djlivooo
Copy link

Hello, people. This happens to me when I'm moving a playlist from Spotify to Youtube Music. Is there any solution?

Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in run_code
File "C:\Users\varga\AppData\Local\Programs\Python\Python312\Scripts\spotify_to_ytmusic.exe_main
.py", line 7, in
File "C:\Users\varga\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotify_to_ytmusic\main.py", line 86, in main
args.func(args)
File "C:\Users\varga\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotify_to_ytmusic\controllers.py", line 71, in create
_create_ytmusic(args, playlist, ytmusic)
File "C:\Users\varga\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotify_to_ytmusic\controllers.py", line 62, in _create_ytmusic
playlistId = ytmusic.create_playlist(
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\varga\AppData\Local\Programs\Python\Python312\Lib\site-packages\spotify_to_ytmusic\ytmusic.py", line 21, in create_playlist
return self.api.create_playlist(name, info, privacy, video_ids=tracks)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\varga\AppData\Local\Programs\Python\Python312\Lib\site-packages\ytmusicapi\mixins\playlists.py", line 226, in create_playlist
response = self._send_request(endpoint, body)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\varga\AppData\Local\Programs\Python\Python312\Lib\site-packages\ytmusicapi\ytmusic.py", line 156, in _send_request
raise Exception(message + error)
Exception: Server returned HTTP 400: Bad Request.
Request contains an invalid argument.

@sigma67
Copy link
Owner

sigma67 commented Nov 11, 2023

It's probably a problem with the way you set up your credentials. Which setup method did you use? Can you check your settings.ini file?

@djlivooo
Copy link
Author

It's probably a problem with the way you set up your credentials. Which setup method did you use? Can you check your settings.ini file?

Use the method as instructed in the Github
First I made the Spotify dashboard. The redirect link is the one from http://localhost. And then I did the authorization by Google OAuth. Although I don't know if that is created automatically or where it is created?

@sigma67
Copy link
Owner

sigma67 commented Nov 13, 2023

If you did everything correctly it should probably work. To troubleshoot you need to manually inspect the settings.ini file, which is created automatically.

It should be in platformdirs.user_cache_dir/spotify_to_ytmusic, depends on your platform where that is

@Lod3
Copy link

Lod3 commented Nov 27, 2023

I am having the same issue as djlivooo
To be fair the playlist has 1002 tracks in it, another playlist transfered fine before I tried the large playlist
I tried to transfer the larger one a second time and it worked.

Anyway I tried to find the settings.ini file you mentioned, I could find the example ini file but not the ehm "real" one?
I use scoop to install applications and used it to install python so it seems it saves installed python packages in its folder structure.
C:\Users\Clovis\scoop\apps\python\current\Lib\site-packages\spotify_to_ytmusic

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Clovis\scoop\apps\python\current\Scripts\spotify_to_ytmusic.exe\__main__.py", line 7, in <module>
  File "C:\Users\Clovis\scoop\apps\python\current\Lib\site-packages\spotify_to_ytmusic\main.py", line 86, in main
    args.func(args)
  File "C:\Users\Clovis\scoop\apps\python\current\Lib\site-packages\spotify_to_ytmusic\controllers.py", line 71, in create
    _create_ytmusic(args, playlist, ytmusic)
  File "C:\Users\Clovis\scoop\apps\python\current\Lib\site-packages\spotify_to_ytmusic\controllers.py", line 60, in _create_ytmusic
    videoIds = ytmusic.search_songs(playlist["tracks"])
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Clovis\scoop\apps\python\current\Lib\site-packages\spotify_to_ytmusic\ytmusic.py", line 32, in search_songs
    result = self.api.search(query)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Clovis\scoop\apps\python\current\Lib\site-packages\ytmusicapi\mixins\search.py", line 165, in search
    response = self._send_request(endpoint, body)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Clovis\scoop\apps\python\current\Lib\site-packages\ytmusicapi\ytmusic.py", line 151, in _send_request
    response_text = json.loads(response.text)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Clovis\scoop\apps\python\current\Lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Clovis\scoop\apps\python\current\Lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Clovis\scoop\apps\python\current\Lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@sigma67
Copy link
Owner

sigma67 commented Jan 22, 2024

@Lod3 the settings file should be in %APPDATA%/spotify_to_ytmusic

@sigma67 sigma67 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 22, 2024
@turmoni
Copy link

turmoni commented Feb 8, 2024

I'm consistently seeing this with trying to import https://open.spotify.com/playlist/3YgiYNSYXeKWPkcVKZY4xc - it is a rather large playlist with thousands of entries, so that seems to match with the original report. I've successfully imported a far smaller one, so I believe my config should be right. I've not yet had the time to investigate further than this, but I thought I'd provide what is (to me) a consistent reproduction of these symptoms.

@sigma67
Copy link
Owner

sigma67 commented Feb 8, 2024

Maybe the issue is that too many videos are being passed to create_playlist.

YouTube's playlist limit is at 5000: https://webapps.stackexchange.com/questions/77790/what-is-the-maximum-youtube-playlist-length

so it is in fact impossible to transfer this playlist. Could implement an exception for this case

@turmoni
Copy link

turmoni commented Feb 17, 2024

Ah, I was wondering if there was some kind of API limit, I hadn't considered that there would just be a playlist size limit, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants