tehkillerbee / mopidy-tidal

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

Errors in log #145

Closed fmarzocca closed 7 months ago

fmarzocca commented 8 months ago

Recently, I am experiencing a lot of errors in the log, like this one:

2024-01-26 04:41:53,633 INFO [625:TidalBackend-3 (_actor_loop)] pykka: Exception returned from TidalBackend (urn:uuid:c12e6639-b865-4eb5-84d0-0aee7dc6d629) to caller:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 186, in _actor_loop
    response = self._handle_receive(envelope.message)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 286, in _handle_receive
    return callee(*message.args, **message.kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/mopidy/backend.py", line 331, in change_track
    uri = self.translate_uri(track.uri)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mopidy_tidal/login_hack.py", line 306, in wrapper
    return fn(obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mopidy_tidal/playback.py", line 36, in translate_uri
    newurl = session.track(track_id).get_url()
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/tidalapi/session.py", line 571, in track
    item = media.Track(session=self, media_id=track_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/tidalapi/media.py", line 86, in __init__
    self._get(self.id)
  File "/usr/local/lib/python3.11/dist-packages/tidalapi/media.py", line 192, in _get
    track = self.requests.map_request("tracks/%s" % media_id, parse=parse)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/tidalapi/request.py", line 129, in map_request
    json_obj = self.request("GET", url, params).json()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/tidalapi/request.py", line 107, in request
    request.raise_for_status()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 1021, in raise_for_status
      raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.tidal.com/v1/tracks/229782957?sessionId=xx&countryCode=IT&limit=1000```

Versions mopidy-tidal==0.3.4 tidalapi==0.7.3

tehkillerbee commented 8 months ago

I had a similar problem this morning but maybe unrelated to the issue you are having. Have you tried logging in again/re-auth (i.e. deleting the file /var/lib/mopidy/tidal/tidal-oauth.json) ?

What quality setting are you using?

fmarzocca commented 8 months ago

I didn't delete the oath.json, will try. quality = LOSSLESS

Could the issue be related to python3.11?

tehkillerbee commented 8 months ago

Could the issue be related to python3.11?

I don't think so, I think the existing tests include python 3.11. I currently use python3.9 and python 3.10.

Does this issue occur with any album? Can you share a link to the album? Maybe playback has been disabled by Tidal.

fmarzocca commented 8 months ago

examples of failing addresses:

url: https://api.tidal.com/v1/tracks/224308115? sessionId=xx&countryCode=IT&limit=1000

TIDAL uri: tidal:track:3684905:224308107:224308115

url: https://api.tidal.com/v1/tracks/114678110? sessionId=xx&countryCode=IT&limit=1000

uri: tidal:track:6454895:114678109:114678110

Edit: removed sessionId

tehkillerbee commented 8 months ago

Can you provide links to these tracks/albums on the tidal web player? I do not seem to be able to access them (album 224308107 and album 114678109) so perhaps they have been removed.

Does playback work with other albums, tracks?

fmarzocca commented 8 months ago

I will try, but maybe they have been removed.

tehkillerbee commented 8 months ago

In https://github.com/tamland/python-tidal/pull/224 I have added some additional log info so that should clarify what causes this issue in the future.

fmarzocca commented 8 months ago

Are you going to release?

tehkillerbee commented 8 months ago

Yes, next release of tidalapi should be released soon. But you can also update from latest master

2e0byo commented 8 months ago

I have had similar issues: at a guess they might be stale cache data? I've noticed btw that the file cache never evicts. Tidal might just have changed the ids for some things.

fmarzocca commented 8 months ago

This morning I had a new one:

2024-02-15 08:30:09,223 ERROR [664:Core-13 (_actor_loop)] mopidy.core.library: TidalBackend backend caused an 
exception.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/mopidy/core/library.py", line 17, in _backend_error_handling
    yield
  File "/usr/lib/python3/dist-packages/mopidy/core/library.py", line 230, in lookup
    result = future.get()
             ^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pykka/_threading.py", line 55, in get
    raise exc_value
  File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 186, in _actor_loop
    response = self._handle_receive(envelope.message)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 286, in _handle_receive
    return callee(*message.args, **message.kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mopidy_tidal/login_hack.py", line 237, in wrapper
    return fn(obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mopidy_tidal/library.py", line 325, in lookup
    data = cache_data = lookup(self._session, parts)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mopidy_tidal/library.py", line 420, in _lookup_track
    track = next(t for t in tracks if t.id == int(track_id))  # pragma: no cover
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
StopIteration
tehkillerbee commented 8 months ago

This morning I had a new one:

2024-02-15 08:30:09,223 ERROR [664:Core-13 (_actor_loop)] mopidy.core.library: TidalBackend backend caused an 
exception.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/mopidy/core/library.py", line 17, in _backend_error_handling
    yield
  File "/usr/lib/python3/dist-packages/mopidy/core/library.py", line 230, in lookup
    result = future.get()
             ^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pykka/_threading.py", line 55, in get
    raise exc_value
  File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 186, in _actor_loop
    response = self._handle_receive(envelope.message)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 286, in _handle_receive
    return callee(*message.args, **message.kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mopidy_tidal/login_hack.py", line 237, in wrapper
    return fn(obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mopidy_tidal/library.py", line 325, in lookup
    data = cache_data = lookup(self._session, parts)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mopidy_tidal/library.py", line 420, in _lookup_track
    track = next(t for t in tracks if t.id == int(track_id))  # pragma: no cover
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
StopIteration

Yep, I got exactly the same one when testing yesterday. It occurs when trying to iterate over tracks in an album that is not available anymore. I have added some extra error handling to avoid that issue in the future and this will be part of the next release of mopidy-tidal.

Most of these confusing errors have been fixed in the next release of mopidy, simply by improving the error handling of both mopidy-tidal and tidalapi.

tehkillerbee commented 7 months ago

All these issues are resolved in #153 #151