tehkillerbee / mopidy-tidal

Tidal Backend plugin for Mopidy
Apache License 2.0
93 stars 28 forks source link

KeyError 'gender'? #123

Closed fmarzocca closed 1 year ago

fmarzocca commented 1 year ago

After months of operations, my mopidy-tidal suddenly started to crash on login error. It always asks me to "visit link ", but after I visit the link, I get this error:

2023-07-08 09:39:38,985 INFO [1253:TidalBackend-6] mopidy_tidal.backend: Visit link.tidal.com/QQYDB to log in, the code will expire in 300 seconds
2023-07-08 09:39:58,460 ERROR [1253:TidalBackend-6] pykka: Unhandled exception in TidalBackend (urn:uuid:bfce567f-177f-4515-9862-c13df05dc0df):
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/pykka/_actor.py", line 179, in _actor_loop
    self.on_start()
  File "/usr/local/lib/python3.9/dist-packages/mopidy_tidal/backend.py", line 83, in on_start
    self.oauth_login_new_session(oauth_file)
  File "/usr/local/lib/python3.9/dist-packages/mopidy_tidal/backend.py", line 29, in oauth_login_new_session
    self._session.login_oauth_simple(function=logger.info)
  File "/usr/local/lib/python3.9/dist-packages/tidalapi/session.py", line 323, in login_oauth_simple
    future.result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 440, in result
    return self.__get_result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.9/dist-packages/tidalapi/session.py", line 364, in _process_link_login
    self.user = tidalapi.User(self, user_id=json['userId']).factory()
  File "/usr/local/lib/python3.9/dist-packages/tidalapi/user.py", line 48, in factory
    return self.request.map_request('users/%s' % self.id, parse=self.parse)
  File "/usr/local/lib/python3.9/dist-packages/tidalapi/request.py", line 118, in map_request
    return self.map_json(json_obj, parse=parse)
  File "/usr/local/lib/python3.9/dist-packages/tidalapi/request.py", line 125, in map_json
    return parse(json_obj)
  File "/usr/local/lib/python3.9/dist-packages/tidalapi/user.py", line 65, in parse
    return user.parse(json_obj)
  File "/usr/local/lib/python3.9/dist-packages/tidalapi/user.py", line 110, in parse
    self.gender = json_obj['gender']
KeyError: 'gender'
2023-07-08 09:39:58,466 ERROR [1253:MainThread] mopidy.commands: Actor died: TidalBackend (urn:uuid:bfce567f-177f-4515-9862-c13df05dc0df) stopped before handling the message

And it never generates the file /var/lib/mopidy/tidal/tidal_oauth.json I am running these versions:

Mopidy-Tidal==0.3.2
tidalapi @ git+https://github.com/BlackLight/python-tidal@91e6b4983d1561a92c149a829781969f2c083cb7
tehkillerbee commented 1 year ago

Hello, this is a known bug (tidal changed some fields around again.)

It's fixed on latest tidalapi master, try to switch to that version instead. https://github.com/tamland/python-tidal/issues/146#event-9745242664

fmarzocca commented 1 year ago

So, just replace my tidalapi with sudo pip3 install tidalapi?

fmarzocca commented 1 year ago

I did remove tidalapi and installed v. 0.7.1 but the error persists. I will apply the patch

tehkillerbee commented 1 year ago

Sorry, the PyPi release has not been updated yet so you can install latest version from tidalapi git.

fmarzocca commented 1 year ago

never mind. I'll keep the patch and wait for next official release. Thanks