sigma67 / ytmusicapi

Unofficial API for YouTube Music
https://ytmusicapi.readthedocs.io
MIT License
1.59k stars 184 forks source link

TypeError: RefreshingToken.__init__() got an unexpected keyword argument 'filepath' #538

Closed linsomniac closed 4 months ago

linsomniac commented 4 months ago

Describe the bug I haven't used my session in days or more, and I believe it's going to refresh the token, but (with version 1.5.2 and also experienced on 1.4.2), I'm getting the following traceback:

Traceback (most recent call last):
  File "/home/sean/.cache/pypoetry/virtualenvs/spotify2ytmusic--SB_8d7f-py3.10/bin/s2yt_list_playlists", line 6, in <module>
    sys.exit(list_playlists())
  File "/home/sean/projects/spotify_to_ytmusic/spotify2ytmusic/cli.py", line 22, in list_playlists
    yt = backend.get_ytmusic()
  File "/home/sean/projects/spotify_to_ytmusic/spotify2ytmusic/backend.py", line 27, in get_ytmusic
    return YTMusic("oauth.json")
  File "/home/sean/.cache/pypoetry/virtualenvs/spotify2ytmusic--SB_8d7f-py3.10/lib/python3.10/site-packages/ytmusicapi/ytmusic.py", line 139, in __init__
    self._token = RefreshingToken(
TypeError: RefreshingToken.__init__() got an unexpected keyword argument 'filepath'

The RefreshingToken() is getting created with a self._input_dict that contains a "filepath": "oauth.json" element.

If I remove the filepath from the dict, it seems to succeed, but I don't know the code well enough to know if that's a bit naive.

Adding above the "RefreshingToken" above (ytmusic.py line 139) which reads:

if 'filepath' in self._input_dict:
    del(self._input_dict['filepath'])

Seemed to work for me.

To Reproduce Steps to reproduce the behavior:

  1. Login with ytmusicapi.
  2. Wait for oauth to time out.
  3. Do YTMusic("oauth.json")
sigma67 commented 4 months ago

_input_dict is what you're passing in via oauth.json

Fix your oauth.json to not contain filepath and you're good to go

linsomniac commented 4 months ago

There is no "filepath" in my "oauth.json", and if there were it is not something that I would have put in there, I created it with "ytmusicapi oauth".

[N] (spotify2ytmusic-py3.10) sean@seans-laptop ~/p/spotify_to_ytmusic (main) [1]> grep -i file oauth.json
[I] (spotify2ytmusic-py3.10) sean@seans-laptop ~/p/spotify_to_ytmusic (main) [1]>
sigma67 commented 4 months ago

536