althonos / InstaLooter

Another API-less Instagram pictures and videos downloader.
GNU General Public License v3.0
2k stars 259 forks source link

get_post_info(): KeyError: 'graphql' #351

Open Aaeeschylus opened 2 years ago

Aaeeschylus commented 2 years ago

Library version

What's the installed library version ? Check with instalooter --version:

instalooter v2.4.4

Environment

Describe here your environment, including:

Error description - runtime

Reproducible test case

from instalooter.looters import PostLooter

# this is straight from the API examples
def links(media, looter):
    if media.get('__typename') == "GraphSidecar":
        media = looter.get_post_info(media['shortcode'])
        nodes = [e['node'] for e in media['edge_sidecar_to_children']['edges']]
        return [n.get('video_url') or n.get('display_url') for n in nodes]
    elif media['is_video']:
        media = looter.get_post_info(media['shortcode'])
        return [media['video_url']]
    else:
        return [media['display_url']]

looter = PostLooter('CSZ_YEelaIV')
for media in looter.medias():
    for link in links(media, looter):
        print(link)

Expected behaviour

I expect to have a link to the image of the post printed.

Actual behaviour

Traceback (most recent call last):
  File "test.py", line 16, in <module>
    for media in looter.medias():
  File "/home/pi/.local/lib/python3.7/site-packages/instalooter/looters.py", line 824, in medias
    info = self.info
  File "/home/pi/.local/lib/python3.7/site-packages/instalooter/looters.py", line 792, in info
    self._info = self.get_post_info(self.code)
  File "/home/pi/.local/lib/python3.7/site-packages/instalooter/looters.py", line 353, in get_post_info
    return data['graphql']['shortcode_media']
KeyError: 'graphql'

Extra comment

This has only started happening as of about 12 hours ago or so (maybe longer but I was asleep). Before then, it had been working fine for months.