mirror of
https://github.com/sigma67/ytmusicapi.git
synced 2026-04-25 07:16:00 +03:00
[GH-ISSUE #721] File name too long error on ytmusicapi authentication because headers are passed to new Path() #471
Labels
No labels
a/b
bug
documentation
enhancement
good first issue
help wanted
invalid
pull-request
question
wontfix
yt-error
yt-update
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ytmusicapi#471
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @0kommanix on GitHub (Jan 15, 2025).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/721
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.
@sigma67 commented on GitHub (Jan 15, 2025):
Yeah that was kinda stupid. PR welcome
@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?
@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
@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?
@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.