From 5a240640126e556ba70c8132ed5e5be5b9ef4ac5 Mon Sep 17 00:00:00 2001 From: Nicolai Weitkemper Date: Mon, 30 May 2022 21:29:34 +0200 Subject: [PATCH 1/3] Fix incorrect error messages when certain requests fail (#1536) - handle case where `Profile.from_id` works, but `Profile.from_username` doesn't - Handle case where `QueryReturnedNotFoundException` lies and `similar_profiles` contains the exact username - Still raises `ProfileNotExistsException` for compatibility. --- instaloader/instaloader.py | 4 ++++ instaloader/structures.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/instaloader/instaloader.py b/instaloader/instaloader.py index 31f8c90..950e6ce 100644 --- a/instaloader/instaloader.py +++ b/instaloader/instaloader.py @@ -1334,6 +1334,10 @@ class Instaloader: profile_id)) profile_from_id = Profile.from_id(self.context, profile_id) newname = profile_from_id.username + if profile_name == newname: + self.context.error( + f"Warning: Profile {profile_name} could not be retrieved by its name, but by its ID.") + return profile_from_id self.context.error("Profile {0} has changed its name to {1}.".format(profile_name, newname)) if latest_stamps is None: if ((format_string_contains_key(self.dirname_pattern, 'profile') or diff --git a/instaloader/structures.py b/instaloader/structures.py index 52b56fd..3957368 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -771,6 +771,9 @@ class Profile: top_search_results = TopSearchResults(self._context, self.username) similar_profiles = [profile.username for profile in top_search_results.get_profiles()] if similar_profiles: + if self.username in similar_profiles: + raise ProfileNotExistsException( + f"Profile {self.username} seems to exist, but could not be loaded.") from err raise ProfileNotExistsException('Profile {} does not exist.\nThe most similar profile{}: {}.' .format(self.username, 's are' if len(similar_profiles) > 1 else ' is', From 90cfeaf471ed2d7f556f7d9e2d1c8ffa0f685968 Mon Sep 17 00:00:00 2001 From: twitter-79 <42436876+twitter-79@users.noreply.github.com> Date: Wed, 8 Jun 2022 18:12:07 +0200 Subject: [PATCH 2/3] Fixed fetching a users profile information (#1561) * fixed fetching a users profile information switched to new api/v1/users/web_profile_info/?username=xy endpoint * fixed non existing users thanks to @Dibort for fixing this! --- instaloader/structures.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/instaloader/structures.py b/instaloader/structures.py index 3957368..ba16b0a 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -764,8 +764,11 @@ class Profile: def _obtain_metadata(self): try: if not self._has_full_metadata: - metadata = self._context.get_json('{}/feed/'.format(self.username), params={}) - self._node = metadata['entry_data']['ProfilePage'][0]['graphql']['user'] + metadata = self._context.get_iphone_json(f'api/v1/users/web_profile_info/?username={self.username}', + params={}) + if metadata['data']['user'] is None: + raise ProfileNotExistsException('Profile {} does not exist.'.format(self.username)) + self._node = metadata['data']['user'] self._has_full_metadata = True except (QueryReturnedNotFoundException, KeyError) as err: top_search_results = TopSearchResults(self._context, self.username) From 853e8603637fa9662c890cacd192387155bd5e99 Mon Sep 17 00:00:00 2001 From: Alexander Graf <17130992+aandergr@users.noreply.github.com> Date: Wed, 8 Jun 2022 18:13:38 +0200 Subject: [PATCH 3/3] Release of Version 4.9.1 --- instaloader/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instaloader/__init__.py b/instaloader/__init__.py index b250340..a5be26e 100644 --- a/instaloader/__init__.py +++ b/instaloader/__init__.py @@ -1,7 +1,7 @@ """Download pictures (or videos) along with their captions and other metadata from Instagram.""" -__version__ = '4.9' +__version__ = '4.9.1' try: