fail to login at startup
Hi, I'm using mopidy_spotify v4.0.1 on armbian buster on nano pi NEO SBC. I see there is an issue with spotify login when login fails on mopidy startup. For example, when there is no internet connection at mopidy startup and the internet connection comes back after couple of minutes spotify backend does not try to login again. To reproduce the issue, the connection must not come back until this log line appears:
ERROR [24188:SpotifyEventLoop] spotify.session: Spotify login error: <ErrorType.UNABLE_TO_CONTACT_SERVER: 8>
I have a solution but i'm not sure if this is correct, but at least it solves the problem for me:
diff --git a/mopidy_spotify/backend.py b/mopidy_spotify/backend.py
index 7cefb48..e4777dc 100644
--- a/mopidy_spotify/backend.py
+++ b/mopidy_spotify/backend.py
@@ -90,6 +90,16 @@ class SpotifyBackend(pykka.ThreadingActor, backend.Backend):
self._logged_out,
backend_actor_proxy,
)
+ def logged_in(session, error_type):
+ if error_type is spotify.ErrorType.OK:
+ logger.error('Logged in as %s' % session.user)
+ else:
+ logger.error('Login failed: %s' % error_type)
+ session.login(
+ self._config["spotify"]["username"],
+ self._config["spotify"]["password"],
+ )
+ session.on(spotify.SessionEvent.LOGGED_IN, logged_in)
session.on(
spotify.SessionEvent.PLAY_TOKEN_LOST,
on_play_token_lost,
Looks like duplicate of #259
See #110, Spotify turned down the library we used with one months notice...
And the fix that is in flight shouldn't have the login issue you describe if I'm not mistaken.
@adamcik The error here looks different from that (ie was still present before the ongoing, note it was reported in Jan)
That's what I get for looking at this first thing in the morning :P
libspotify has been removed, this issue won't occur in the latest version (but I fully expect one like it might so please reopen if so.