From 610b6242a067a33cefdfb4db48854c467af59e3d Mon Sep 17 00:00:00 2001 From: Alexander Graf <17130992+aandergr@users.noreply.github.com> Date: Mon, 8 Jun 2020 17:53:39 +0200 Subject: [PATCH] Get higher image quality if logged-in Addresses a suggestion in #630. --- instaloader/structures.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/instaloader/structures.py b/instaloader/structures.py index a5245cc..7994113 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -242,7 +242,9 @@ class Post: """URL of the picture / video thumbnail of the post""" if self.typename == "GraphImage" and self._context.is_logged_in: try: - return self._iphone_struct['image_versions2']['candidates'][0]['url'] + orig_url = self._iphone_struct['image_versions2']['candidates'][0]['url'] + url = re.sub(r'&se=\d+(&?)', r'\1', orig_url) + return url except (InstaloaderException, KeyError, IndexError) as err: self._context.error('{} Unable to fetch high quality image version of {}.'.format(err, self)) return self._node["display_url"] if "display_url" in self._node else self._node["display_src"] @@ -266,7 +268,8 @@ class Post: if not is_video and self._context.is_logged_in: try: carousel_media = self._iphone_struct['carousel_media'] - display_url = carousel_media[idx]['image_versions2']['candidates'][0]['url'] + orig_url = carousel_media[idx]['image_versions2']['candidates'][0]['url'] + display_url = re.sub(r'&se=\d+(&?)', r'\1', orig_url) except (InstaloaderException, KeyError, IndexError) as err: self._context.error('{} Unable to fetch high quality image version of {}.'.format(err, self)) yield PostSidecarNode(is_video=is_video, display_url=display_url,