From b583cd07e11ed1c1d0124ec78aa2eda7e9ff676d Mon Sep 17 00:00:00 2001 From: Alexander Graf <17130992+aandergr@users.noreply.github.com> Date: Sat, 27 Mar 2021 20:22:03 +0100 Subject: [PATCH] Get better-quality version of pictures if logged-in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1065 (also see #630). Co-Authored-By: André Koch-Kramer --- instaloader/structures.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/instaloader/structures.py b/instaloader/structures.py index 6cca9e4..cf6e9ce 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -249,7 +249,7 @@ class Post: if self.typename == "GraphImage" and self._context.is_logged_in: try: orig_url = self._iphone_struct['image_versions2']['candidates'][0]['url'] - url = re.sub(r'&se=\d+(&?)', r'\1', orig_url) + url = re.sub(r'([?&])se=\d+&?', r'\1', orig_url).rstrip('&') return url except (InstaloaderException, KeyError, IndexError) as err: self._context.error('{} Unable to fetch high quality image version of {}.'.format(err, self)) @@ -308,7 +308,7 @@ class Post: try: carousel_media = self._iphone_struct['carousel_media'] orig_url = carousel_media[idx]['image_versions2']['candidates'][0]['url'] - display_url = re.sub(r'&se=\d+(&?)', r'\1', orig_url) + display_url = re.sub(r'([?&])se=\d+&?', r'\1', orig_url).rstrip('&') except (InstaloaderException, KeyError, IndexError) as err: self._context.error('{} Unable to fetch high quality image version of {}.'.format( err, self)) @@ -1082,7 +1082,7 @@ class StoryItem: if self.typename == "GraphStoryImage" and self._context.is_logged_in: try: orig_url = self._iphone_struct['image_versions2']['candidates'][0]['url'] - url = re.sub(r'&se=\d+(&?)', r'\1', orig_url) + url = re.sub(r'([?&])se=\d+&?', r'\1', orig_url).rstrip('&') return url except (InstaloaderException, KeyError, IndexError) as err: self._context.error('{} Unable to fetch high quality image version of {}.'.format(err, self))