2

can someone show me how to add a time delay to instaloader.py a code snippet of a working time delay inside the instaloadercontext.py i just want to add a custom delay once a return limit of 60 is reached to do_sleep for an hour before the next query.

in the below code ,class RateController is providing request tracking and rate controlling to stay within rate limits.

It can be overridden to change Instaloader's behavior regarding rate limits, for example to raise a custom exception when the rate limit is hit

   import instaloader

   class MyRateController(instaloader.RateController):
       def sleep(self, secs):
           raise MyCustomException()

   L = instaloader.Instaloader(rate_controller=lambda ctx: MyRateController(ctx))
Asmoun
  • 1,417
  • 5
  • 20
  • 53

1 Answers1

0

Since nobody replied, I was wondering if you were able to solve your question?

By the way, the MyRateController class can do more than just "sleep".

class MyRateController(instaloader.RateController):
    def sleep(self, secs: float):
        return super().sleep(secs)
    def handle_429(self, query_type: str) -> None:
        return super().handle_429(query_type)
    def query_waittime(self, query_type: str, current_time: float, untracked_queries: bool = False) -> float:
        return super().query_waittime(query_type, current_time, untracked_queries)
    def wait_before_query(self, query_type: str) -> None:
        return super().wait_before_query(query_type)
Texxi
  • 1
  • 1