linsomniac / spotify_to_ytmusic

Copy playlists and liked music from Spotify to YTMusic
Creative Commons Zero v1.0 Universal
2.11k stars 131 forks source link

ERROR: Unable to look up song on YTMusic: Server returned HTTP 400: Bad Request. Request contains an invalid argument. #125

Open JDMys opened 2 weeks ago

JDMys commented 2 weeks ago

When I go to the “Load liked song” step and press the “Load” button, I get the following message for YTMUSIC: ERROR: Unable to look up song on YTMusic: Server returned HTTP 400: Bad Request. Request contains an invalid argument.

I tried to upgrade ytmusicapi: pip install ytmusicapi --upgrade --user upgrading to version 1.8.2. I try again the “Load liked song” step and get the same result: ERROR: Unable to look up song on YTMusic: Server returned HTTP 400: Bad Request. Request contains an invalid argument. image

krabbypattybackpain commented 1 week ago

I am also facing this problem, if anybody has a solution it would help a lot. Thanks

Dingolord commented 1 week ago

Having the same issue as well and cannot for the life of me figure out the fix, i just wanna send my spotify over so i can reduce my subscriptions 😭

rnbw-spctrm commented 1 week ago

This is likely related to an issue in a library that has an open ticket and recent responses by a dev: https://github.com/sigma67/ytmusicapi/issues/676

jjrossi commented 1 week ago

Getting the same issue but with a twist:

context:

All commands work fine (listing, importing, etc) when used with my google account, but I get the error (400) when I run the commands via my wife and kids accounts.

binums commented 1 week ago

Same issue here. I tried using my master account for YouTube Premium family like @jjrossi mentioned and everything worked.

Not a solution to the original problem though

danthomas25 commented 6 days ago

Same problem. "ERROR: Unable to look up song on YTMusic: Server returned HTTP 400: Bad Request. Request contains an invalid argument."

kevinkrieger commented 6 days ago

Same issue here, using command line on linux (windows subsystem for linux, ubuntu). Downloading all the information from spotify works fine, but any request to yt fails with the HTTP 400: Bad Request error.

krabbypattybackpain commented 5 days ago

I have a solution. Search up Tune My Music on google then click "let's start". Proceed with the steps to move your spotify playlist to youtube music. The limit for each transfer is 500 songs, after in which Tune My Music will then ask for a subscription. To bypass this just close the tab and open a new one to repeat the whole process again.

ohadklein11 commented 5 days ago

The issue is with google no longer supporting oauth authentication. Here's what worked for me - following alternative authentication issue by sigma67:

  1. Open a new tab, enter developer mode (ctrl+shift_i), enter 'Network' tab. Filter using the filter textbox by: /browse
  2. Go to https://music.youtube.com/ (while connected to your desired account) and click 'Library' at the sidebar.
  3. In your developer mode inspector you will see a new request under 'Name' which starts with 'browse?', click it, manually select and copy everything under 'Request Headers'.
  4. In terminal, run 'ytmusicapi browser', paste the headers you've just copied, press Enter, press ctrl+D. A new file 'browser.json' should be created in your current dir.
  5. Change in your installed spotify2ytmusic package's source code: above this line in backend.py write 'return YTMusic("browser.json")'.

Following these 5 steps you should be able to use this tool as before. Hope this helps!

P.S. If you're confused about step 3, here's what you should copy (until the end of 'Request Headers') & how you should (at the very top of the image) filter to find the request: image

SjioGG commented 5 days ago

The issue is with google no longer supporting oauth authentication. Here's what worked for me - following alternative authentication issue by sigma67:

  1. Open a new tab, enter developer mode (ctrl+shift_i), enter 'Network' tab. Filter using the filter textbox by: /browse
  2. Go to https://music.youtube.com/ (while connected to your desired account) and click 'Library' at the sidebar.
  3. In your developer mode inspector you will see a new request under 'Name' which starts with 'browse?', click it, manually select and copy everything under 'Request Headers'.
  4. In terminal, run 'ytmusicapi browser', paste the headers you've just copied, press Enter, press ctrl+D. A new file 'browser.json' should be created in your current dir.
  5. Change in your installed spotify2ytmusic package's source code: above [this line in backend.py] write 'return YTMusic("browser.json")'.

Following these 5 steps you should be able to use this tool as before. Hope this helps!

P.S. If you're confused about step 3, here's what you should copy (until the end of 'Request Headers') & how you should (at the very top of the image) filter to find the request: image

"this line" is line 28 in backend.py

27 try:
28  return YTMusic("oauth.json") # change this
Dingolord commented 5 days ago

update nvm i found it for anyone wanting the path for where to find backend.py this is where i found mine C:\Program Files\Python313\Lib\site-packages\spotify2ytmusic good luck and god speed

kriso812 commented 3 days ago

Hi I seem to be having this same issue and I am attempting this solution, but my ytmusicapi browser command does not appear to work. This is what I am getting, forgive me if I am doing some terribly basic error:

PS C:\Users\Name> py -m ytmusicapi browser
C:\Users\Name\AppData\Local\Programs\Python\Python313\python.exe: No module named ytmusicapi.__main__; 'ytmusicapi' is a package and cannot be directly executed

I also don't see a browse?ctoken= network request, only a prettyprint one (the first one in the image)

danthomas25 commented 3 days ago

The latest pull request on this has the details. You need to change 4 .py files in the package. Details in files here: https://github.com/linsomniac/spotify_to_ytmusic/pull/132

Dont forget first to do the stuff here to build the browser.json file: https://github.com/linsomniac/spotify_to_ytmusic/issues/125#issuecomment-2481207542

kimlehtinen commented 3 days ago

Hi I seem to be having this same issue and I am attempting this solution, but my ytmusicapi browser command does not appear to work. This is what I am getting, forgive me if I am doing some terribly basic error:

PS C:\Users\Name> py -m ytmusicapi browser
C:\Users\Name\AppData\Local\Programs\Python\Python313\python.exe: No module named ytmusicapi.__main__; 'ytmusicapi' is a package and cannot be directly executed

I also don't see a browse?ctoken= network request, only a prettyprint one (the first one in the image)

I had same issue on Windows. Try using venv.

python -m venv myenv
.\myenv\Scripts\activate.bat
pip install ytmusicapi
ytmusicapi browser

Then continue using @ohadklein11 instructions

kriso812 commented 3 days ago

I've updated my files to what was in the pull request, but I still can't seem to get to the point where I can build the browser. still running into the problem where it won't let me run ytmusicapi browser. I'm using windows powershell and my PATH is set up to include the python scripts

PS C:\Users\Name> py -m venv myenv
PS C:\Users\Name> .\myenv\Scripts\activate.bat
PS C:\Users\Name> py -m pip install ytmusicapi
Requirement already satisfied: ytmusicapi in c:\users\Name\appdata\local\programs\python\python313\lib\site-packages (1.8.2)
Requirement already satisfied: requests>=2.22 in c:\users\Name\appdata\local\programs\python\python313\lib\site-packages (from ytmusicapi) (2.32.3)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\Name\appdata\local\programs\python\python313\lib\site-packages (from requests>=2.22->ytmusicapi) (3.4.0)
Requirement already satisfied: idna<4,>=2.5 in c:\users\Name\appdata\local\programs\python\python313\lib\site-packages (from requests>=2.22->ytmusicapi) (3.10)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\Name\appdata\local\programs\python\python313\lib\site-packages (from requests>=2.22->ytmusicapi) (2.2.3)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\Name\appdata\local\programs\python\python313\lib\site-packages (from requests>=2.22->ytmusicapi) (2024.8.30)

[notice] A new release of pip is available: 24.2 -> 24.3.1
[notice] To update, run: C:\Users\Name\AppData\Local\Programs\Python\Python313\python.exe -m pip install --upgrade pip
PS C:\Users\Name> py -m ytmusicapi browser
C:\Users\Name\AppData\Local\Programs\Python\Python313\python.exe: No module named ytmusicapi.__main__; 'ytmusicapi' is a package and cannot be directly executed
danthomas25 commented 3 days ago

I just straight used cmd, I see ur in Powershell, dunno if mkes a difference, worth a try

kimlehtinen commented 3 days ago

Yes use command prompt instead of powershell:

C:\example>python -m venv myenv

C:\example>.\myenv\Scripts\activate.bat

(myenv) C:\example>pip install ytmusicapi
Collecting ytmusicapi
  Using cached ytmusicapi-1.8.2-py3-none-any.whl.metadata (5.5 kB)
Collecting requests>=2.22 (from ytmusicapi)
...

(myenv) C:\example>ytmusicapi browser
Creating browser.json with your authentication credentials...
Please paste the request headers from Firefox and press 'Enter, Ctrl-Z, Enter' to continue:
TozeMoonster commented 2 days ago

How am i supposed to get that ctoken browser request every time i try to i can only get pretty print one

kriso812 commented 2 days ago

Yes use command prompt instead of powershell:

C:\example>python -m venv myenv

C:\example>.\myenv\Scripts\activate.bat

(myenv) C:\example>pip install ytmusicapi
Collecting ytmusicapi
  Using cached ytmusicapi-1.8.2-py3-none-any.whl.metadata (5.5 kB)
Collecting requests>=2.22 (from ytmusicapi)
...

(myenv) C:\example>ytmusicapi browser
Creating browser.json with your authentication credentials...
Please paste the request headers from Firefox and press 'Enter, Ctrl-Z, Enter' to continue:

awesome, I have it working now so far, thanks everybody for the help!

How am i supposed to get that ctoken browser request every time i try to i can only get pretty print one

I used the pretty print one and it worked

VladPav04 commented 17 hours ago

Hello everybody. I'm trying to paste all the Request Headers into macOS terminal, but it seems it has a paste limit and will not paste all the headers. Can somebody please tell me how have you managed to paste all the Request Headers into Terminal? Than you in advance and wish you all a great day.

vatnid commented 12 hours ago

Hello everybody. I'm trying to paste all the Request Headers into macOS terminal, but it seems it has a paste limit and will not paste all the headers. Can somebody please tell me how have you managed to paste all the Request Headers into Terminal? Than you in advance and wish you all a great day.

After you copy the request headers, run pbpaste | ytmusicapi browser instead

VladPav04 commented 11 hours ago

Thank you! This worked like a charm!

On Fri, Nov 22, 2024, 18:13 Samuel Lo @.***> wrote:

Hello everybody. I'm trying to paste all the Request Headers into macOS terminal, but it seems it has a paste limit and will not paste all the headers. Can somebody please tell me how have you managed to paste all the Request Headers into Terminal? Than you in advance and wish you all a great day.

After you copy the request headers, run pbpaste | ytmusicapi browser instead

— Reply to this email directly, view it on GitHub https://github.com/linsomniac/spotify_to_ytmusic/issues/125#issuecomment-2494124941, or unsubscribe https://github.com/notifications/unsubscribe-auth/BIZS6KHP7VHZGAJ3CPXSZX32B5J37AVCNFSM6AAAAABRHZ5OBCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJUGEZDIOJUGE . You are receiving this because you commented.Message ID: @.***>

dalskics commented 34 minutes ago

Yes use command prompt instead of powershell:

C:\example>python -m venv myenv

C:\example>.\myenv\Scripts\activate.bat

(myenv) C:\example>pip install ytmusicapi
Collecting ytmusicapi
  Using cached ytmusicapi-1.8.2-py3-none-any.whl.metadata (5.5 kB)
Collecting requests>=2.22 (from ytmusicapi)
...

(myenv) C:\example>ytmusicapi browser
Creating browser.json with your authentication credentials...
Please paste the request headers from Firefox and press 'Enter, Ctrl-Z, Enter' to continue:

awesome, I have it working now so far, thanks everybody for the help!

How am i supposed to get that ctoken browser request every time i try to i can only get pretty print one

I used the pretty print one and it worked

I tried the print one and it did not work :( - any ideas??? - no ctoken is generating on youtube music