From 3fa225f7fa01d0378bfb064ed9dffcbf7d754863 Mon Sep 17 00:00:00 2001 From: Ryan Luu Date: Thu, 4 Jul 2024 12:41:49 +0000 Subject: [PATCH] Add refresh interval --- src/instagram_to_discord.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/instagram_to_discord.py b/src/instagram_to_discord.py index 25f838d..1a953d0 100644 --- a/src/instagram_to_discord.py +++ b/src/instagram_to_discord.py @@ -19,6 +19,7 @@ TARGET_INSTAGRAM_PROFILE = input("Enter the Instagram account you want monitor: ") DISCORD_WEBHOOK_URL = input("Enter the Discord webhook URL: ") +REFRESH_INTERVAL = 3600 L = instaloader.Instaloader() @@ -58,7 +59,7 @@ def check_for_new_posts(): posts = profile.get_posts() until = datetime.now() - since = until.replace(hour=until.hour-1) # Check for posts in the last hour + since = until.replace(hour=until.second-REFRESH_INTERVAL) # Check for posts in the last hour for post in takewhile(lambda p: p.date > until, dropwhile(lambda p: p.date > since, posts)): instagram_post_url = "https://instagram.com/p/" + post.shortcode + "/" @@ -82,4 +83,4 @@ def check_for_new_posts(): while __name__ == "__main__": check_for_new_posts() - time.sleep(3600) + time.sleep(REFRESH_INTERVAL)