subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024
https://hikerapi.com/p/bkXQlaVe
MIT License
4.37k stars 684 forks source link

[BUG] Missing key "graphql" in /instagrapi/mixins/public.py in the public_a1_request. #1298

Closed birdhouses closed 1 year ago

birdhouses commented 1 year ago

Describe the bug Missing key "graphql" in /instagrapi/mixins/public.py in the public_a1_request.

To Reproduce Provide a piece of code to reproduce the problem.

Traceback Traceback (most recent call last): File "/home/user/Code/python/instabot/instabot/comment.py", line 26, in comment_on_media posts_to_comment = cl.hashtag_medias_recent(comment_on_tag, amount_per_day) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/micromamba/envs/python311/lib/python3.11/site-packages/instagrapi/mixins/hashtag.py", line 423, in hashtag_medias_recent medias = self.hashtag_medias_recent_a1(name, amount) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/micromamba/envs/python311/lib/python3.11/site-packages/instagrapi/mixins/hashtag.py", line 386, in hashtag_medias_recent_a1 return self.hashtag_medias_a1(name, amount, tab_key="edge_hashtag_to_media") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/micromamba/envs/python311/lib/python3.11/site-packages/instagrapi/mixins/hashtag.py", line 221, in hashtag_mediasa1 medias, = self.hashtag_medias_a1_chunk(name, amount, tab_key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/micromamba/envs/python311/lib/python3.11/site-packages/instagrapi/mixins/hashtag.py", line 165, in hashtag_medias_a1_chunk data = self.public_a1_request( ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/micromamba/envs/python311/lib/python3.11/site-packages/instagrapi/mixins/public.py", line 212, in public_a1_request raise e File "/home/user/micromamba/envs/python311/lib/python3.11/site-packages/instagrapi/mixins/public.py", line 204, in public_a1_request return response["graphql"]


KeyError: 'graphql'
birdhouses commented 1 year ago

Might investigate this myself later. Seems like public_a1_request shouldn't be checking for a graphql key in the response because it is not calling the graphql api. Haven't investigated yet! If anyone could help, thanks!

birdhouses commented 1 year ago

This seems to be an issue with my particular program. I'm using async functions to follow/ unfollow/ comment. As the bot is "sleeping" it passes the client from the follow task to the comment task. The Client state is not being reset thus causing conficts between the responses.