Skip to content
This repository was archived by the owner on May 9, 2026. It is now read-only.

Commit ab4734b

Browse files
committed
fix(session): allow offline viewing by wrapping authenticate in try block
1 parent 93d0f6a commit ab4734b

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

viu_cli/cli/interactive/session.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,25 @@ def selector(self) -> "BaseSelector":
111111
@property
112112
def media_api(self) -> "BaseApiClient":
113113
if not self._media_api:
114+
import httpx
115+
114116
from ...libs.media_api.api import create_api_client
115117

116118
media_api = create_api_client(self.config.general.media_api, self.config)
117119

118120
auth = self.auth
119121
if auth_profile := auth.get_auth():
120-
p = media_api.authenticate(auth_profile.token)
121-
if p:
122-
logger.debug(f"Authenticated as {p.name}")
123-
else:
124-
logger.warning(f"Failed to authenticate with {auth_profile.token}")
122+
try:
123+
p = media_api.authenticate(auth_profile.token)
124+
if p:
125+
logger.debug(f"Authenticated as {p.name}")
126+
else:
127+
logger.warning(
128+
f"Failed to authenticate with {auth_profile.token}"
129+
)
130+
except httpx.ConnectError as e:
131+
logger.warning(f"It seems you are offline: {e}")
132+
125133
else:
126134
logger.debug("Not authenticated")
127135
self._media_api = media_api

0 commit comments

Comments
 (0)