From 9961312d340ad64fdd379a400a4d4b80dc2c207b Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 8 May 2018 18:15:17 +0200 Subject: [PATCH] Fix anonymous retry on profile that blocked viewer --- instaloader/structures.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/instaloader/structures.py b/instaloader/structures.py index 764a10b..137305b 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -365,6 +365,8 @@ class Profile: def from_username(cls, context: InstaloaderContext, username: str): """Create a Profile instance from a given username, raise exception if it does not exist. + See also :meth:`Instaloader.check_profile_id`. + :param context: :attr:`Instaloader.context` :param username: Username :raises: :class:`ProfileNotExistsException` @@ -412,8 +414,8 @@ class Profile: metadata = self._context.get_json('{}/'.format(self.username), params={}) self._node = metadata['entry_data']['ProfilePage'][0]['graphql']['user'] self._rhx_gis = metadata['rhx_gis'] - except QueryReturnedNotFoundException: - raise ProfileNotExistsException('Profile {} does not exist.'.format(self.username)) + except (QueryReturnedNotFoundException, KeyError) as err: + raise ProfileNotExistsException('Profile {} does not exist.'.format(self.username)) from err def _metadata(self, *keys) -> Any: try: