From 82a709bb35bda519afdd3f5d960e64c9eac0576c Mon Sep 17 00:00:00 2001 From: Nirvana Date: Tue, 17 Feb 2026 17:59:13 +0100 Subject: [PATCH] Add discovery --- .../providers/discovery/auth.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/streaming_providers/providers/discovery/auth.py b/lib/streaming_providers/providers/discovery/auth.py index 7fd0fa0..3dcd486 100644 --- a/lib/streaming_providers/providers/discovery/auth.py +++ b/lib/streaming_providers/providers/discovery/auth.py @@ -944,15 +944,18 @@ class DiscoveryAuthenticator(BaseAuthenticator): self._restore_session_cookie(token.st_cookie) # Upgrade anonymous stored token when user credentials are available. - # The base class loads whatever was saved — if a previous run only got - # as far as anonymous auth, we should upgrade now rather than operate - # with restricted access. - is_anonymous_token = ( - not isinstance(token, DiscoveryAuthToken) or - getattr(token, "anonymous", True) - ) + # The base class may return a BaseAuthToken (not DiscoveryAuthToken) when + # loading from storage, so we read the anonymous flag from the raw token + # info dict rather than inspecting the object type. + token_info = self.get_token_info() or {} + is_anonymous_token = token_info.get("anonymous", True) has_user_credentials = isinstance(self.credentials, DiscoveryUserCredentials) + logger.debug( + f"Token state: anonymous={is_anonymous_token}, " + f"has_user_credentials={has_user_credentials}" + ) + if is_anonymous_token and has_user_credentials: logger.info( "Stored token is anonymous but user credentials are available "