Skip to content

get_post_info(): KeyError: 'graphql' #351

@Aaeeschylus

Description

@Aaeeschylus

Library version

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

instalooter v2.4.4

Environment

Describe here your environment, including:

  • OS - Raspbian GNU/Linux 10 (buster)
  • Python version - 3.7.3

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions