subzeroid / instagrapi

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

[BUG] New uncatched PleaseWaitFewMinutes exception #1476

Open themrcatsu opened 1 year ago

themrcatsu commented 1 year ago

Hi.

Seems like instagram made some update, and now PleaseWaitFewMinutes exception catched like ClientError This happends cause of status code is 401 which is not checked inside _send_private_request

Message of response when i get - Please wait a few minutes before you try again. seems to be the same as before

adw0rd commented 1 year ago

Yes, interesting, I'll try to reproduce. Thanks!

adw0rd commented 1 year ago

It looks like 401 status works fine

    396 message = last_json.get("message", "")
    397 if "Please wait a few minutes" in message:
--> 398     raise PleaseWaitFewMinutes(e, response=e.response, **last_json)
    399 if e.response.status_code == 403:
    400     if message == "login_required":

PleaseWaitFewMinutes: Please wait a few minutes before you try again.

In [12]: cl.last_json
Out[12]:
{'message': 'Please wait a few minutes before you try again.',
 'require_login': True,
 'status': 'fail'}

In [13]: cl.last_response.status_code
Out[13]: 401
themrcatsu commented 1 year ago

Im using 1.18.1, and i dont have check like on your code example.

im-kuro commented 1 year ago

Not sure if this is the same issue but it seems Instagram changed something in their API. I've been trying to use cl.get_followers and cl.get_following although it rate limits me hard. I have time.sleep(random.randint(20, 30)) between each call and i'm not calling the API a lot. And after the API timeout is over, i can't use the saved settings from the last login and i have to re-login.

This is the exception ive been getting during rate limits instagrapi.exceptions.ClientError: Please wait a few minutes before you try again.

After the rate limit if i try the same settings all cl.get_followers or cl.get_following returns is {}

adw0rd commented 1 year ago

@themrcatsu try instagrapi 1.18.2

themrcatsu commented 1 year ago

Im facing almost same as @im-kuro, after some calls to api, i got login required, im doing client.relogin(), and got ReloginAttemptExceeded, but im calling directly to hashtag_medias_v1_chunk i got LoginRequired even with public api, just tested, and i tested, this accounts are not banned or something, i can login to account in browser, how to bypass that?

themrcatsu commented 1 year ago

@adw0rd Just checked a bit more, it seems like public requests have something changed

  1. When i loaded settings from file, i got ReloginRequired and then ReloginAttemptExceeded
  2. When i deleted settings file, and made public request, it stuck forever - im calling hashtag_medias_a1_chunk
adw0rd commented 1 year ago

for a1/gql (public API) you can try calling cl.inject_sessionid_to_public() before

https://adw0rd.github.io/instagrapi/usage-guide/interactions.html

im-kuro commented 1 year ago

I've updated to v1.18.2 and implemented cl.inject_sessionid_to_public() before any interaction calls and am still seeing login/API call issues

themrcatsu commented 1 year ago

@adw0rd Now its not stucked, i got 'graphql' KeyError for first time, then i added prints to debug, and seems like i got some response, but now again i have login required


Interesting thing that i got exact LoginRequired instance, which is not raised anywhere in public part of api