diff --git a/src/instawebhooks/__main__.py b/src/instawebhooks/__main__.py index ef9f098..1611118 100644 --- a/src/instawebhooks/__main__.py +++ b/src/instawebhooks/__main__.py @@ -226,11 +226,13 @@ async def check_for_new_posts(): new_posts_found = False - for post in posts: + for post in takewhile( + lambda p: p.date > until, dropwhile(lambda p: p.date > since, posts) + ): new_posts_found = True logger.debug("New post found: https://www.instagram.com/p/%s", post.shortcode) await send_to_discord(post) - sleep(20) # Avoid 30 requests per minute rate limit + sleep(2) # Avoid 30 requests per minute rate limit if not new_posts_found: logger.debug("No new posts found.")