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

File name too long error on ytmusicapi authentication because headers are passed to new Path() #721

Closed
0kommanix opened this issue Jan 15, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@0kommanix
Copy link

  1. Installed spotify_to_ytmusic via pipx (got v0.5.1)
  2. Since OAuth is no longer an opzion for ytmusicapi, I chose the Browser Cookie option of authenticating and copied the headers.
  3. when invoking spotify_to_ytmusic I get the following error:

File ".local/pipx/venvs/spotify-to-ytmusic/lib/python3.9/site-packages/ytmusicapi/ytmusic.py", line 128, in init
if (auth_path := Path(auth_str)).is_file():
File "/usr/lib/python3.9/pathlib.py", line 1439, in is_file
return S_ISREG(self.stat().st_mode)
File "/usr/lib/python3.9/pathlib.py", line 1221, in stat
return self._accessor.stat(self)
OSError: [Errno 36] File name too long: '<HEADER_CONTENT>'

...with HEADER_CONTENT being the value of [youtube].headers

Looks like ytmusic.py is check if provided self.auth is a file name but since spotify_to_ytmusic passes the headers which are quite long, Python complains that the file name string is too long when trying to create a Path() instance out of the passed header string.

@0kommanix 0kommanix changed the title File name too long error on ytmusic authentication File name too long error on ytmusicapi authentication because headers are passed to new Path() Jan 15, 2025
@sigma67 sigma67 added the bug Something isn't working label Jan 15, 2025
@sigma67
Copy link
Owner

sigma67 commented Jan 15, 2025

Yeah that was kinda stupid. PR welcome

@sigma67 sigma67 transferred this issue from sigma67/spotify_to_ytmusic Jan 15, 2025
@0kommanix
Copy link
Author

0kommanix commented Jan 16, 2025

I have a fix ready but was unable to successfully verify because I am still getting 401 with browser-based approach.

I read something about YT Family accounts not working anymore with browser-based authentication and the need to switch to Oauth with Google Cloud Console account. Could that be the cause for the 401?

@sigma67
Copy link
Owner

sigma67 commented Jan 16, 2025

No, both methods should work with any account. Although I'm not the owner in my family plan so I can't personally verify

@0kommanix
Copy link
Author

0kommanix commented Jan 16, 2025

I just can't get browser auth to work with spotify_to_ytmusic for my account (which is a member of a family account, not the owner, just like your setup). This used to work.

I just tried OAuth with spotify_to_ytmusic but I think that it is no longer compatible with the 1.9.x versions of ytmusicapi as the config file and codebase is missing client_secret when trying to setup OAuth from sporitfy_to_ytmusic. Will open another bug with sporitfy_to_ytmusic project.

Created a PR for the browser auth Path issue anyway but I am not familiar with Python and it looks like I didn't get the syntax right?

sigma67 added a commit that referenced this issue Jan 17, 2025
@0kommanix
Copy link
Author

Thanks @sigma67 for providing a fix.

I also wanted to report back that my browser auth issue has been resolved. Unfortunately, I was using a YouTube cookie instead of a YouTube Music cookie. Although logged-in with the same account, apparently the credentials are not interchangeable.

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

2 participants