From 3e0cc291c7d8613e8f35a4eb694e62cbb07e97ec Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Thu, 1 Aug 2024 20:51:46 -0700 Subject: [PATCH] Fix post check --- src/instawebhooks/__main__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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.")