[GH-ISSUE #721] File name too long error on ytmusicapi authentication because headers are passed to new Path() #471

Closed
opened 2026-02-27 23:00:58 +03:00 by kerem · 5 comments
Owner

Originally created by @0kommanix on GitHub (Jan 15, 2025).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/721

  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.

Originally created by @0kommanix on GitHub (Jan 15, 2025). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/721 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.
kerem 2026-02-27 23:00:58 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@sigma67 commented on GitHub (Jan 15, 2025):

Yeah that was kinda stupid. PR welcome

<!-- gh-comment-id:2593186610 --> @sigma67 commented on GitHub (Jan 15, 2025): Yeah that was kinda stupid. PR welcome
Author
Owner

@0kommanix commented on GitHub (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?

<!-- gh-comment-id:2595913900 --> @0kommanix commented on GitHub (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?
Author
Owner

@sigma67 commented on GitHub (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

<!-- gh-comment-id:2595934566 --> @sigma67 commented on GitHub (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
Author
Owner

@0kommanix commented on GitHub (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?

<!-- gh-comment-id:2596207328 --> @0kommanix commented on GitHub (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?
Author
Owner

@0kommanix commented on GitHub (Jan 18, 2025):

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.

<!-- gh-comment-id:2599804169 --> @0kommanix commented on GitHub (Jan 18, 2025): 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 in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ytmusicapi#471
No description provided.