1
0
mirror of https://github.com/instaloader/instaloader.git synced 2024-08-18 12:49:38 +02:00

Get higher image quality if logged-in

Addresses a suggestion in #630.
This commit is contained in:
Alexander Graf 2020-06-08 17:53:39 +02:00
parent d90f90988a
commit 610b6242a0

View File

@ -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,