Skip to content

Commit

Permalink
Add refresh interval
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanLua authored Jul 4, 2024
1 parent a7f308e commit 3fa225f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/instagram_to_discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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 + "/"
Expand All @@ -82,4 +83,4 @@ def check_for_new_posts():

while __name__ == "__main__":
check_for_new_posts()
time.sleep(3600)
time.sleep(REFRESH_INTERVAL)

0 comments on commit 3fa225f

Please sign in to comment.