1
0
mirror of https://github.com/instaloader/instaloader.git synced 2024-07-04 19:05:55 +02:00

Detect errors when checking if the user is logged in

This commit is contained in:
Eduardo M KALINOWSKI 2024-05-25 08:41:55 -03:00 committed by Alexander Graf
parent 7d0e46798e
commit 0c7398882b

View File

@ -243,8 +243,12 @@ class InstaloaderContext:
def test_login(self) -> Optional[str]:
"""Not meant to be used directly, use :meth:`Instaloader.test_login`."""
data = self.graphql_query("d6f4427fbe92d846298cf93df0b937d3", {})
return data["data"]["user"]["username"] if data["data"]["user"] is not None else None
try:
data = self.graphql_query("d6f4427fbe92d846298cf93df0b937d3", {})
return data["data"]["user"]["username"] if data["data"]["user"] is not None else None
except (AbortDownloadException, ConnectionException) as err:
self.error(f"Error when checking if logged in: {err}")
return None
def login(self, user, passwd):
"""Not meant to be used directly, use :meth:`Instaloader.login`.