Skip to content

Commit

Permalink
Add login check
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanLua authored Jul 14, 2024
1 parent f25b9cc commit 5f356d3
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/instawebhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from time import sleep

import requests
from instaloader import Instaloader, Post, Profile
from instaloader import Instaloader, LoginRequiredException, Post, Profile
from requests.exceptions import HTTPError


Expand Down Expand Up @@ -67,6 +67,21 @@ def discord_webhook_url(arg_value: str):
# Log the start of the program
logger.info("Starting InstaWebhooks...")

try:
Profile.from_username(
Instaloader().context, args.instagram_username).get_posts()
except LoginRequiredException as login_error:
logger.critical(
"""instaloader: error: %s\n
You're not logged into Instaloader. Login to your Instagram account in Instaloader using:
instaloader --login YOUR-USERNAME
or
instaloader --load-cookies BROWSER-NAME
Instaloader Documentation: https://instaloader.github.io/cli-options.html#login-download-private-profiles
""", login_error)
exit(1)


def create_embed_json(post: Post):
"""Create a Discord embed object from an Instagram post"""
Expand Down

0 comments on commit 5f356d3

Please sign in to comment.